Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
M3N0Hax -7
5 years ago

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.

0
Is it local script or script? fortesss7 40 — 5y
0
WalkSpeed should not be changed locally. DeceptiveCaster 3761 — 5y
0
its a local script# M3N0Hax -7 — 5y

3 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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

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. M3N0Hax -7 — 5y
0
that works fine for me? what errors you got NubScripters 126 — 5y
0
https://gyazo.com/8c7daab06fb52d1455c8ca795407b882 That is what it should look like NubScripters 126 — 5y
0
oh i see i didnt insert the frame M3N0Hax -7 — 5y
Ad
Log in to vote
0
Answered by
Dleppyy 41
5 years ago
Edited 5 years ago

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)

0
enderdragonkk38 thanks so much, it works. M3N0Hax -7 — 5y
0
Do you know what ill have to change for it to change other values such as Jump? M3N0Hax -7 — 5y
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. Dleppyy 41 — 5y
0
also click "Accept Answer" so it can help other people that need it. Dleppyy 41 — 5y
View all comments (2 more)
0
That's the same script I just did.... fortesss7 40 — 5y
0
no u messed yours up Dleppyy 41 — 5y
Log in to vote
-1
Answered by 5 years ago
Edited 5 years ago

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

0
hello fortesss7, unfortunatley your script didnt work. sorry M3N0Hax -7 — 5y
0
It didn't work because he didn't use a remote event. Poor answer U_srname 152 — 5y

Answer this question