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

Why does my script work fine in studio, but does not work at all in the actual game?

Asked by 6 years ago

Hello! Hope you are all fine :P Well the problem is that with the (local) script below, is that it works perfectly in studio, but it doesn't work at all in game.. Can anyone help ;-;

Yes its all the script and anyone can copy it but whatever Ooof

01local player = game.Players.LocalPlayer
02local desaa = false
03local debounce = true
04local punch = true
05local ipit = game:GetService("UserInputService")
06local char = game.Workspace:WaitForChild(player.Name)
07local arm = char.RightHand
08 
09 
10local punchanimation = Instance.new("Animation")
11punchanimation.AnimationId = "http://www.roblox.com/Asset?ID=2837641618"
12 
13local kickanimation = Instance.new("Animation")
14kickanimation.AnimationId = "http://www.roblox.com/Asset?ID=2796826423"
15 
View all 70 lines...
0
bc that's just Studio: some stuff only works in-game DeceptiveCaster 3761 — 6y
0
Can yah reccomend meh a way to fix it :thinking: ScriptingNubs 55 — 6y
0
It is probably due to character loading longer (arm may not exist) . Just add longer (like wait(10)) on line 18 and see if it works. If it does, find a better solution like player.CharacterAdded sleazel 1287 — 6y

1 answer

Log in to vote
0
Answered by
sleazel 1287 Moderation Voter
6 years ago

Try changing line 07:

1local arm = char.RightHand

to:

1local arm = char:WaitForChild("RightHand")

as right arm may not have loaded yet.

Ad

Answer this question