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

Changing value from LocalPlayer not working?

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 comment

1

Add a wait() to the while true do

2 answers

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.

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

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