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

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

Asked by 5 years ago
Edited 5 years ago
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

0
There's a question mark in end User#24403 69 — 5y
0
Also you should be using the Running event and use the Character property User#24403 69 — 5y
0
The questionmark was a accident when copied tightanfall 110 — 5y
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. namespace25 594 — 5y

1 answer

Log in to vote
0
Answered by
Leamir 3138 Moderation Voter Community Moderator
5 years ago

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

0
You should be using the Character property . User#24403 69 — 5y
Ad

Answer this question