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

How come this script comes up with an 'Unexpected Symbol' Error?

local player = game.Players.LocalPlayer
local ls = player:WaitForChild('leaderstats')
local Points = ls.Points


while true do
	wait(0.5)
	if game.Workspace[player.Name].Character.Humanoid.MoveDirection.Magnitude > 0 then
		Points.Value = Points.Value +1
	end
end)

It's supposed to add points to the player when player is moving

4 comments

0

There's a question mark in end

0

Also you should be using the Running event and use the Character property

0

The questionmark was a accident when copied

0

using game:GetService("RunService").Stepped:Connect(function() end) is a better way than saying while wait(.5) do, because it is called every frame.

1 answer

Hello, tightanfall!

local player = game.Players.LocalPlayer
local ls = player:WaitForChild('leaderstats')
local Points = ls.Points


while true do
    wait(0.5)
    if game.Workspace[player.Name].Humanoid.MoveDirection.Magnitude > 0 then -- The .Character here was causing the problem, as when using game.Workspace[player.Name] you already get the character
        Points.Value = Points.Value +1
    end
end)

Hope this helps, if not post a comment below

Good Luck with your games

1 comment

0

You should be using the Character property .

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