Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why would a script work in studio test but not in game?

Asked by 9 years ago

I'm testing something I made and it's not working in game, but it works perfectly in studio.

I'm posting the script, but I mainly want to know what kind of things would cause a script to do this.

I don't really want an edited script (I won't reject it though) I would like a hint or something on where to find my error. I prefer to learn from mistakes rather then have people solve them

tool=script.Parent
player = script.Parent.Parent.Parent
mouse = player:GetMouse()

tool.Activated:connect(function()
     local clone = game.Lighting.Dummy:Clone()
    clone.Parent = game.Workspace

    clone.Torso.CFrame = CFrame.new(mouse.Hit.p + Vector3.new(0, 3, 0)) --Adding Vector3's
end)


0
my problem was that if it was in a local script, it was loading before the player got there so i always used wait(0.5) before it executed the rest of the script yogipanda123 120 — 9y

1 answer

Log in to vote
0
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
9 years ago

Accessing the player from the client should be through game.Players.LocalPlayer. Any script that runs locally on the client is supposed to be a LocalScript. Often times when a script in a tool doesn't work, adding a delay at the beginning solves the problem.

0
I put it in a local script, I will keep this in mind next time. Tempestatem 884 — 9y
Ad

Answer this question