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

Changing value from LocalPlayer not working?

Asked by 8 years ago

I want to change the Value of motorbike speed (Working for an upgrade system) but I am not able to change the value of the value inside of the bike. Does anyone see a workaround?

local players = game.Players.LocalPlayer
local genUpgrade = game.Workspace.Players.Motorcycle.Value

while true do
    genUpgrade.Value = genUpgrade.Value + 20
end

Cheers,

Michael.

1
Add a wait() to the while true do Azmidium 388 — 8y

2 answers

Log in to vote
1
Answered by 8 years ago

Well, I can see 2 problems that poke my eye.

genUpgrade = game.Workspace.Players.Motorcycle.Value

You store the value of Motorcycle, which won't work as you will only increment the variable, not the actual property of Motorcycle. You should instead do:

genUpgrade = game.Workspace.Players.Motorcycle

Second, you should never EVER do a loop without wait's. Instead, do this: while wait() do

Hope this helped.

Ad
Log in to vote
0
Answered by
Im_Kritz 334 Moderation Voter
8 years ago
local players = game.Players.LocalPlayer
local genUpgrade = game.Workspace.Players.Motorcycle

while true do
wait()
    genUpgrade.Value = genUpgrade.Value + 20
end

Do you have an instance named "Players" in workspace or did you make a mistake?

If you do, my code should work

Answer this question