This script works in studio but not in-game. No output. Its in a LocalScript in PlayerGui.
local Player = game.Players.LocalPlayer local Camera = game.Workspace.CurrentCamera local SS = game:WaitForChild("ServerStorage") local ItemMesh = SS.CrateMeshes local Crate = SS.Crate Ready = true function OnClick() if Ready == true then Ready = false local Pad = Instance.new("Part") Pad.Name = "CrateLand" Pad.Size = Vector3.new(5, 5, 5) Pad.Anchored = true Pad.CanCollide = false Pad.Transparency = 1 Pad.BrickColor = BrickColor.new("Bright red") Pad.Position = Vector3.new(Player.Character.Torso.Position.X, Player.Character.Torso.Position.Y, Player.Character.Torso.Position.Z-5) Pad.Parent = Camera local Number = math.random(1,500) print(Number) local CrateCopy = Crate:Clone() CrateCopy.PrimaryPart = CrateCopy.Main CrateCopy.PrimaryPart.Position = Vector3.new(Camera.CrateLand.Position.X, Camera.CrateLand.Position.Y + 50, Camera.CrateLand.Position.Z) CrateCopy.Lid.Number.Value = Number if Number <= 75 then --75/500 Chance ItemMesh.Axe:Clone().Parent = CrateCopy.Item CrateCopy.Lid.ItemID.Value = 1 elseif Number <= 125 then --50/500 Chance ItemMesh.Katana:Clone().Parent = CrateCopy.Item CrateCopy.Lid.ItemID.Value = 2 elseif Number <= 175 then --50/500 Chance ItemMesh.EnergySword:Clone().Parent = CrateCopy.Item CrateCopy.Lid.ItemID.Value = 3 elseif Number <= 250 then --75/500 Chance ItemMesh.BlackIronMace:Clone().Parent = CrateCopy.Item CrateCopy.Lid.ItemID.Value = 4 elseif Number <= 251 then --1/500 Chance ItemMesh.Darkheart:Clone().Parent = CrateCopy.Item CrateCopy.Lid.ItemID.Value = 5 elseif Number <= 270 then --19/500 Chance ItemMesh.Kodachi:Clone().Parent = CrateCopy.Item CrateCopy.Lid.ItemID.Value = 6 elseif Number <= 350 then --80/500 Chance ItemMesh.ClassicSword:Clone().Parent = CrateCopy.Item CrateCopy.Lid.ItemID.Value = 5 elseif Number <= 450 then --100/500 Chance ItemMesh.Board:Clone().Parent = CrateCopy.Item CrateCopy.Lid.ItemID.Value = 8 elseif Number <= 500 then --50/500 Chance ItemMesh.BluesteelClaw:Clone().Parent = CrateCopy.Item CrateCopy.Lid.ItemID.Value = 9 end CrateCopy.Parent = Camera wait(5) Camera:FindFirstChild("CrateLand"):Destroy() Ready = true end end script.Parent.MouseButton1Click:connect(OnClick)
Your 'error' is that WaitForChild is forever waiting, because ServerStorage isn't replicated to the client.
Consider using ReplicatedStorage or ReplicatedFirst instead. Also, I'd recommend using game:GetService()
or game:FindService()
.