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
local Plr = game.Players.LocalPlayer local Humanoid = Plr.Character:WaitForChild("Humanoid") local Tool = script.Parent; enabled = true function onActivated() if not enabled then return end enabled = false Tool.GripForward = Vector3.new(-0, -0.836, -0.549) Tool.GripPos = Vector3.new(1.4, -0.4, 0.3) Tool.GripRight = Vector3.new(0.996, -0.0509, 0.0776) Tool.GripUp = Vector3.new(0.0928, 0.547, -0.832) Tool.Handle.DrinkSound:Play() Humanoid.WalkSpeed = Humanoid.WalkSpeed +.5 game.Players.LocalPlayer.leaderstats.Speed.Value = game.Players.LocalPlayer.leaderstats.Speed.Value +3 wait(3) local h = Tool.Parent:FindFirstChild("Humanoid") if (h ~= nil) then if (Tool.Parent:FindFirstChild("SpeedEffect") == nil) then local s = script.Parent.SpeedEffect:Clone() s.Disabled = false s.Parent = Tool.Parent end end Tool.GripForward = Vector3.new(-.976,0,-0.217) Tool.GripPos = Vector3.new(0.2,-.1,0) Tool.GripRight = Vector3.new(.217,0,-.976) Tool.GripUp = Vector3.new(0,1,0) wait(1) enabled = true end script.Parent.Activated:connect(onActivated)
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
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...
local Humanoid = Plr.Character:WaitForChild("Humanoid")
Try...
local chr = Plr.Character if chr == nil then repeat -- do nothing. until chr ~= nil or chr == true -- This repeat loop will keep running until the character is valid. It will then continue the script. end 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.