Click and substract speed buttons

  1. What do you want to achieve? Keep it simple and clear! two buttons able to add speed and substract soeed

  2. What is the issue? i cant script

so i want a button that doesnt set your speed to a point but adds speed or substracts. like if you click it you get +2 speed and if you click the other one you speed gets -2

what are you trying to do?

What should clicking the button add a value to? An Int value? A variable containing a number?
The “What you want to achieve” section doesn’t tell much.


here is an outline :

 local button = script.Parent -- GUI object
 value = 0

 button.MouseButton1Click:Connect(function()
        value = value + 2 -- add 2?
      print(value)
  end)

for the other just subtract (-) instead.

not really into a gui. so this is what i have: two blocks (buttons) that when one is clicked, it adds 2 speed to the player that clicked it. when the other one is clicked, it substracts 2 speed from the player that clicked it. what i should have*

I’m guessing he’s using a part with ClickDetector.

yes, long story short, im making a character size changer game, one part makes the player grow and the other shrink, so i wanted to make it that if someone clicks the grow button you would also become faster otherwise it looks weird seeing someone big walk slow, and the shrink makes slower. the size changing is already done but now i need a way to add and substract speed through a clickdetector script

Similar concept, like @XxELECTROFUSIONxX said.

local clickDetector = script.Parent
 
clickDetector.MouseClick:Connect(function(player)
    player.Character.Humanoid.WalkSpeed =  player.Character.Humanoid.WalkSpeed + 2
end

The opposite if it’s reducing the speed.

1 Like

thanks! in a script or local script?

You should put this script under the ClickDetector itself. Local script don’t run within workspace.

any, if local then in some place it works, i.e a descendant of the Player.

Personally I’d say the opposite, I think that a cool game mechanic would be that the bigger someone is the slower they move. It gives smaller people a better advantage in the game. Of course I don’t know anything about the context of your game, but take agar.io for example - it works really well because of the speed mechanic.