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

How to I make a button that changes the player's walkspeed when clicked?

I am working on a game and I have added this pet, and when the button to buy it is clicked, I want the walkspeed of the player to be set higher to give the impression that the pet is given the person a power of walking faster.

3 comments

0

Is it local script or script?

0

WalkSpeed should not be changed locally.

0

its a local script#

3 answers

What you need: Local script / Normal script / Remote Event / GUI

In The frame put the local script and a button Edit the button name in the local script provided below

put in local script:

script.Parent.Button.MouseButton1Click:Connect(function() -- Edit button to your buttons Name
    game.ReplicatedStorage.ChangeWalkSpeed:FireServer(50)
end)

Create a remote event and name it "ChangeWalkSpeed" and put it in ReplicatedStorage

Create a script and put it in ServerScriptService and add this code:

game.ReplicatedStorage.ChangeWalkSpeed.OnServerEvent:Connect(function(player, Speed)
	player.Character.Humanoid.WalkSpeed = tonumber(Speed)
end)

Tell me if it works!

Edit: Had two errors in local script just fixed

4 comments

0

sorry but it dosent work :( I have been trying for 2 days now and im running out of ideas. I am making a pet sim sort of game but I cant get past the pet shop part.

0

that works fine for me? what errors you got

0

https://gyazo.com/8c7daab06fb52d1455c8ca795407b882 That is what it should look like

0

oh i see i didnt insert the frame

In local script (That's in the Button)

local Speed = 0 -- change this to the number of speed you want


script.Parent.MouseButton1Click:Connect(function()
	game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = (Speed)
end)

Haven't tested so idk if it'll work

Also if your making when you equip a pet, you should have it to when the pet is equipped it'll have a passive boost of speed. (To prevent people from getting speed by just clicking the button)

6 comments

0

enderdragonkk38 thanks so much, it works.

0

Do you know what ill have to change for it to change other values such as Jump?

0

yeah just change WalkSpeed to JumpPower and make it over 50 if u want to jump higher or lower if u want to jump less. Also click accept answer on this answer so other people can see how to do this.

0

also click "Accept Answer" so it can help other people that need it.

0

That's the same script I just did....

0

no u messed yours up

If it is a local script, here is what you do:

local button = script.Parent
button.MouseButton1Click:connect:(function()
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = (Your speed)
end)

Accept answer if I was useful! Any questions? Add me! MedMike#2018

2 comments

0

hello fortesss7, unfortunatley your script didnt work. sorry

0

It didn't work because he didn't use a remote event. Poor answer

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