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

Why wont the conveyor belt speed change?

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!

1 answer

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.

3 comments

0

sorry for the late response

0

sorry for the late response. When your script was applied It didn't change the variable nor the speed, though thanks for trying

0

oh wait im just dumb sorry you're right

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