local player = game.Players.LocalPlayer local mouse = player.getMouse() plr = game.Players.Player.Name:findFirstChild("Player") pt1 = plr.Torso mag = (pt1.Position - script.Parent.Position).magnitude plr.Humanoid.Running:connect(function(speed) print(mag) if mag <= 15 then print(mag) end end) function getDistance() print ("h") return player.Character and player:DistanceFromCharacter(script.Parent.Position) or math.huge end while wait() do print ("1") if getDistance() < 20 then V=V+1 game.Workspace.TextValue.Value = V print(V) else V=V-1 game.Workspace.TextValue.Value = V end print(V) end
I'm getting this error: Script:2: attempt to index local 'player' (a nil value)
local player = game.Players.LocalPlayer local mouse = player:GetMouse() -- You put Player.GetMouse(), it's player:GetMouse() plr = game.Players.Player.Name:findFirstChild("Player") pt1 = plr.Torso mag = (pt1.Position - script.Parent.Position).magnitude plr.Humanoid.Running:connect(function(speed) print(mag) if mag <= 15 then print(mag) end end) function getDistance() print ("h") return player.Character and player:DistanceFromCharacter(script.Parent.Position) or math.huge end while wait() do print ("1") if getDistance() < 20 then V=V+1 game.Workspace.TextValue.Value = V print(V) else V=V-1 game.Workspace.TextValue.Value = V end print(V) end