Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)


1 comment

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

1 answer

✓ Accepted answer

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.

1 comment

0

I put it in a local script, I will keep this in mind next time.

This discussion is preserved as it was. New answers, comments, and votes are closed.