Hi I'm making a conveyor belt speed changer it can either increase or decrease the speed but for now I want it to increase the speed
so when I click the button the value changes but not the speed of the conveyor belt
the conveyor script:
local Number = game.Workspace.GameHandeler.Number.Value while true do script.Parent.Velocity = script.Parent.CFrame.lookVector *Number wait(0.1) end
the click script:
local jam = script.Parent.Number.Value local Clicker = game.Workspace.increasebutton.increas.Clickincrease function Clicked() jam = jam + 10 end Clicker.MouseClick:Connect(Clicked)
i'm using number values as my storage
I'm new to scripting so any tips would be nice!
I believe you have to move the "local jam = script.Parent.Number.Value" to inside of the function on the click script. I think it'll work if you do this:
local Clicker = game.Workspace.increasebutton.increas.Clickincrease function Clicked() local jam = script.Parent.Number.Value jam = jam + 10 end Clicker.MouseClick:Connect(Clicked)
The reasoning is because you're setting the "jam" value to equal whatever it is at first. That will cause the value to ALWAYS = 5, for example. When the function is called, the variable isn't updated, and is instead only created and updated once. I hope I explained it ok.
The fix makes it so that the "jam" variable will update every time the function is called, simply by moving the variable to inside of that function.