My drink script gives me the error on the title when I use it out of Roblox Studio. Please help me fix it. Here is the script: It says the error is on line 3
01 | local Plr = game.Players.LocalPlayer |
02 |
03 | local Humanoid = Plr.Character:WaitForChild( "Humanoid" ) |
04 |
05 | local Tool = script.Parent; |
06 |
07 |
08 | enabled = true |
09 |
10 |
11 |
12 |
13 | function onActivated() |
14 | if not enabled then |
15 | return |
Character of a player isn't supposed to be managed as a child of player, but a property.
Between line 1 and 3 just add
1 | local char = plr.Character or plr.CharacterAdded:wait() |
it always seem to work for me :)
For some reason, the Character property bugs many scripts.
Instead of...
1 | local Humanoid = Plr.Character:WaitForChild( "Humanoid" ) |
Try...
1 | local chr = Plr.Character |
2 | if chr = = nil then |
3 | repeat |
4 | -- do nothing. |
5 | until chr ~ = nil or chr = = true |
6 | -- This repeat loop will keep running until the character is valid. It will then continue the script. |
7 |
8 | end |
9 | local Humanoid = Plr.Character:FindFirstChild( "Humanoid" ) -- The Humanoid is packed with the Character model already. |
I haven't tested it. It's Midnight here in the Philippines so chances are it might fail.
Hoped I helped if it worked otherwise.