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.
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
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)
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