Help to script walkspeed

This is a NON-local script

Workspace
– Part
— ClickDetector
— Script ← this in not inside the ClickDetector

local part = script.Parent
local normSpeed = 16
local fastSpeed = 32
local isFast = false

local function onButtonClicked(player)
	local character = player.Character

	if isFast then isFast = false
		character.Humanoid.WalkSpeed = normSpeed
		part.BrickColor = BrickColor.new("Bright red")
	else isFast = true
		character.Humanoid.WalkSpeed = fastSpeed
		part.BrickColor = BrickColor.new("Lime green")
	end
end

part.ClickDetector.MouseClick:Connect(onButtonClicked)

I checked this one and it is working. Make the part “Bright red” to start.

bro thanks for the help, but I don’t need it as I said earlier and also threw off the video:

I need to do so, look in the lower right corner

I told you the wrong thing, please excuse me

That is not a part sitting on the workspace as the tutorial did.

I need from the starter GUI and not from Workspace

I’ll repost this lower in the thread.

And after downloading, what to do, where to throw off the file? Or there is a Roblox Studio icon

if the nursery works, I’ll click on the solution and that’s it

Should just make everything for itself. Just drop it in StarterPlayer.StarterPlayerScripts
and hit play

I’m sitting right now from the phone, I’m just after downloading, what should I do, or will I understand myself?

ok thank you hope will work again, sorry for confusing you so much and thanks again

Ya I did what you’re doing for a week and came up with that. All in one. It seems we had the same ideal! Should be fine on any screen also. Your next error would have been a stutter when you switch.
That is why it’s using tween to make that transition smoother. Also apart in there I was working on a just standing still icon. (they are remd’ out atm)

This script would need a different script checking speed to stop hackers.

If you’re making a game like “Speed Simulator” and you want the player’s speed to return to the speed they had, you should create an Integer Value through a server script, parent it to the player’s character, and this value will store however much speed the player gains. With this IntValue obj, you can refer to it from multiple scripts.

local players = game:GetService("Players")

players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(character)
		local speedValue = Instance.new("IntValue")
		speedValue.Name = "Speed" -- Whatever you want to name it, just an example
		speedValue.Parent = character -- Parents the IntValue to the player's character
	end)
end)

(This code would belong in a ServerScript, store it in the ServerScriptService)
Above is an example of adding said IntValue into the character. That being said, to save the value of speed, you’d have to touch into datastores and what-not, but using that local script @2112Jay made, make sure there are variables referencing the player’s character and the IntValue, then assign the SprintSpeed variable to the IntValue. Hope this helps.

Chances are, you probably want to tie the IntValue to the leaderboard for players to see what not. There are bunch of videos out there explaining how to create a leaderboard with the build-in system roblox already has.

bro, I downloaded the file but an error pops up can you give me a script?

I just tested it and it’s working fine. That download don’t need anything. It has the GUI within it. Go down to StarterPlayer.StarterPlayerScripts right click on that and insert from file. You don’t need to do anything else. This works on Mobile or PC, the delete key is also a sprint.

Here is a cleaned up version … make sure you place it in the right spot.
SprintGui.rbxm (8.5 KB)

Put this in a localscript as the child of your button

image

local button = script.Parent
local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")

local enabled = false

button.MouseButton1Click:Connect(function()
	if enabled then --turn button OFF
		humanoid.WalkSpeed = 16
		enabled = false
	else --turn button ON
		humanoid.WalkSpeed = 32
		enabled = true
	end
end)

bro, I need a script, let’s say a player has 32 speeds and then a local player presses a button, his speed becomes 16 and when he presses it, his speed becomes the same

Ok, lets try to figure this out, because its a bit difficult understanding exactly what you are needing help with.

We have a player who is walking at a default speed or starting speed (PlayerA)
Who will press the button to make him walk slower? Is it (PlayerA) on his own GUI, or another player?

When you say his speed becomes 16 and when he press it, his speed becomes the same? The same was what? as his original start speed of 32?

Are you wanting a player to start at speed 32, has a button that he can press to make his speed 16, then press the same button again to set his speed to 32 again?

look at the player, that is, 1 player, I don’t mean the whole server, I mean 1 player, he presses the button and his speed becomes initial and when he presses it again, the speed returns you played there, let’s say a super power fighting simulator there is a button there and a local player presses there and his speed becomes initial

I apologize for the mistakes I use with the translator