Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local runService = game:GetService("RunService")
- local replicatedStorage = game:WaitForChild("ReplicatedStorage")
- local replicatedFirst = game:WaitForChild("ReplicatedFirst")
- local remotes = replicatedStorage:WaitForChild("Remotes")
- local pets = replicatedFirst:WaitForChild("Pets")
- local tweenService = game:GetService("TweenService")
- local player = game.Players.LocalPlayer
- local playerGui = player:WaitForChild("PlayerGui")
- local screenGui = playerGui:WaitForChild("ScreenGui")
- local center = screenGui:WaitForChild("Center")
- local petInventory = center:WaitForChild("PetInventory")
- local scrollingFrame = petInventory:WaitForChild("ScrollingFrame")
- local template = scrollingFrame:WaitForChild("Template")
- local module3D = require(replicatedStorage:WaitForChild("Module3D"))
- local maxSelectedPets = 10
- local selectedPets = 0
- local function onTemplateClick(clickedTemplate, id)
- local equipped = clickedTemplate.Equipped.Value
- if not equipped and selectedPets < maxSelectedPets then
- clickedTemplate.Equipped.Value = true
- tweenService:Create(
- clickedTemplate,
- TweenInfo.new(0.4),
- {
- BackgroundColor3 = Color3.fromRGB(96,235,36)
- }
- ):Play()
- selectedPets = selectedPets + 1
- remotes.EquipPet:FireServer(clickedTemplate.Name, id)
- elseif equipped then
- clickedTemplate.Equipped.Value = false
- tweenService:Create(clickedTemplate,
- TweenInfo.new(0.4),
- {
- BackgroundColor3 = Color3.fromRGB(46,189,255)
- }
- ):Play()
- selectedPets = selectedPets - 1
- remotes.UnequipPet:FireServer(clickedTemplate.Name, id)
- end
- end
- local function createTemplate(petName, id)
- local newTemplate = template:Clone()
- newTemplate.Name = petName
- newTemplate.Visible = true
- newTemplate.Parent = scrollingFrame
- local petModel3D = module3D:Attach3D(
- newTemplate:WaitForChild("Viewport"),
- pets:WaitForChild(petName):Clone())
- petModel3D:SetDepthMultiplier(2)
- petModel3D.CurrentCamera.FieldOfView = 5
- petModel3D.Visible = true
- runService.RenderStepped:Connect(function()
- petModel3D:SetCFrame(
- CFrame.Angles(
- 0,
- tick() % (math.pi * 2), 0) * CFrame.Angles(math.rad(-10), 0, 0))
- end)
- newTemplate.MouseButton1Click:Connect(function()
- onTemplateClick(newTemplate, id)
- end)
- end
- remotes:WaitForChild("CreateTemplate").OnClientEvent:Connect(function(name, id)
- createTemplate(name, id)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement