This works in studio but not in game.
local Player = game.Players.LocalPlayer local Camera = game.Workspace.CurrentCamera local SS = game:WaitForChild("ServerStorage") 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 = 0.5 Pad.BrickColor = BrickColor.new("Bright red") Pad.Position = Vector3.new(Player.Character.Torso.Position.X +10, Player.Character.Torso.Position.Y, Player.Character.Torso.Position.Z) Pad.Parent = Camera 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.Parent = Camera wait(5) Camera:FindFirstChild("CrateLand"):Destroy() Ready = true end end script.Parent.MouseButton1Click:connect(OnClick)
Ah Yes, This Error Is Quite Annoying...
I've encounter this error multiple times and have not been able to figure it out. You see, whenever you start a game, the script is auto loaded, so it pretty much loads so quickly, it doesn't work. All you have to do is use the nifty code; WaitForChid
, WaitForChild
is a useful function to have the script Wait for the child of the object and then execute the code. So to insert it into your code above, you're gonna have to insert it into the variables. Such as this
local Camera = game.Workspace:WaitForChild("CurrentCamera")--This will wait until the 'CurrentCamera' is ready.
So just like you did with ServerStorage, you have to do this with game.Players.LocalPlayer
, SS.Crate
, etc.
GreekGodOfMLG