SHOW:
|
|
- or go back to the newest paste.
1 | local runService = game:GetService("RunService") | |
2 | local replicatedStorage = game:WaitForChild("ReplicatedStorage") | |
3 | local replicatedFirst = game:WaitForChild("ReplicatedFirst") | |
4 | ||
5 | local remotes = replicatedStorage:WaitForChild("Remotes") | |
6 | ||
7 | local eggs = workspace:WaitForChild("Eggs") | |
8 | ||
9 | local pets = replicatedFirst:WaitForChild("Pets") | |
10 | ||
11 | local tweenService = game:GetService("TweenService") | |
12 | ||
13 | local player = game.Players.LocalPlayer | |
14 | local playerGui = player:WaitForChild("PlayerGui") | |
15 | local screenGui = playerGui:WaitForChild("ScreenGui") | |
16 | local center = screenGui:WaitForChild("Center") | |
17 | local petInventory = center:WaitForChild("PetInventory") | |
18 | local scrollingFrame = petInventory:WaitForChild("ScrollingFrame") | |
19 | local template = scrollingFrame:WaitForChild("Template") | |
20 | ||
21 | local module3D = require(replicatedStorage:WaitForChild("Module3D")) | |
22 | ||
23 | local maxSelectedPets = 10 | |
24 | ||
25 | local selectedPets = 0 | |
26 | ||
27 | local function onTemplateClick(clickedTemplate, id) | |
28 | ||
29 | local equipped = clickedTemplate.Equipped.Value | |
30 | ||
31 | if not equipped and selectedPets < maxSelectedPets then | |
32 | clickedTemplate.Equipped.Value = true | |
33 | tweenService:Create( | |
34 | clickedTemplate, | |
35 | TweenInfo.new(0.4), | |
36 | { | |
37 | BackgroundColor3 = Color3.fromRGB(96,235,36) | |
38 | } | |
39 | ):Play() | |
40 | selectedPets = selectedPets + 1 | |
41 | remotes.EquipPet:FireServer(clickedTemplate.Name, id) | |
42 | elseif equipped then | |
43 | clickedTemplate.Equipped.Value = false | |
44 | tweenService:Create(clickedTemplate, | |
45 | TweenInfo.new(0.4), | |
46 | { | |
47 | BackgroundColor3 = Color3.fromRGB(46,189,255) | |
48 | } | |
49 | ):Play() | |
50 | selectedPets = selectedPets - 1 | |
51 | remotes.UnequipPet:FireServer(clickedTemplate.Name, id) | |
52 | end | |
53 | end | |
54 | ||
55 | local function createTemplate(petName, id) | |
56 | local newTemplate = template:Clone() | |
57 | newTemplate.Name = petName | |
58 | newTemplate.Visible = true | |
59 | newTemplate.Parent = scrollingFrame | |
60 | ||
61 | local petModel3D = module3D:Attach3D( | |
62 | newTemplate:WaitForChild("Viewport"), | |
63 | pets:WaitForChild(petName):Clone()) | |
64 | ||
65 | petModel3D:SetDepthMultiplier(2) | |
66 | petModel3D.CurrentCamera.FieldOfView = 5 | |
67 | petModel3D.Visible = true | |
68 | ||
69 | runService.RenderStepped:Connect(function() | |
70 | petModel3D:SetCFrame( | |
71 | CFrame.Angles( | |
72 | 0, | |
73 | tick() % (math.pi * 2), 0) * CFrame.Angles(math.rad(-10), 0, 0)) | |
74 | end) | |
75 | ||
76 | newTemplate.MouseButton1Click:Connect(function() | |
77 | onTemplateClick(newTemplate, id) | |
78 | end) | |
79 | end | |
80 | ||
81 | remotes:WaitForChild("CreateTemplate").OnClientEvent:Connect(function(name, id) | |
82 | createTemplate(name, id) | |
83 | end) | |
84 | ||
85 | ||
86 | local function Opening(pet, id, egg) | |
87 | local eggMesh = eggs:FindFirstChild(egg) | |
88 | eggMesh.ProximityPrompt.Enabled = false | |
89 | eggMesh.Transparency = 1 | |
90 | local petModel = pets:FindFirstChild(pet):Clone() | |
91 | petModel.PrimaryPart.Position = eggMesh.Position | |
92 | petModel.Parent = workspace | |
93 | wait(5) | |
94 | petModel:Destroy() | |
95 | eggMesh.Transparency = 0 | |
96 | eggMesh.ProximityPrompt.Enabled = true | |
97 | createTemplate(pet, id) | |
98 | end | |
99 | ||
100 | ||
101 | remotes:WaitForChild("Egg").OnClientEvent:Connect(Opening) |