WalkSpeedIncreased when part touched dousent work

Trying to make a part that increases your speed when touching it and resets your speed when you stopped touching it. Its weird since it prints 100 as walkspeed but it dousent actually increase the walkspeed

local getplr = game.ReplicatedStorage.GetLocalPlr
getplr.OnServerEvent:Connect(function(plr)
local part = script.Parent
local hum = plr.Character:FindFirstChild("Humanoid")
print(plr)

part.Touched:Connect(function()
	print("speed")
	hum.WalkSpeed = 100
	print(hum.WalkSpeed)
end)

part.TouchEnded:Connect(function()
	print("Slow")
	hum.WalkSpeed = 16
	print(hum.WalkSpeed)
end)
end)

Hello, is it just only doing hum.WalkSpeed? like add

its chancing the hum walkspeed, when i try to print the walkspeed it also says 100 but my actual walkspeed remains the same i dont really understand ur question tho

I understood, so when someone doesn’t touch then it doesn’t change. I’m right?

actually when someone touches it, he starts walking faster but when he stops touching it, his walkspeed becomes normal

Thats litterally what you are doing bro.
Remove:

part.TouchEnded:Connect(function()
	print("Slow")
	hum.WalkSpeed = 16
	print(hum.WalkSpeed)
end)

to stop that

Or dont throw it in a local script?
What special type of script is this my dude. Why cant you make a script in the part itself and do it from there?


local debounce = false

part.Touched:Connect(function()
if debounce == true then return end
	print("speed")
debounce = true
	hum.WalkSpeed = 100
	print(hum.WalkSpeed)
end)

part.TouchEnded:Connect(function()
if debounce == false then return end
	print("Slow")
	hum.WalkSpeed = 16
	print(hum.WalkSpeed)
debounce = false
end)

yh but even when i removed that piece of code it still didint work, lemme send a screenshot

What are you trying to do again? Change speed?

I didn’t quite understand what the problem… if the speed returns after someone doesn’t touch then I didn’t quite understand what the problem exactly.

yes im trying to do that but its not working
image

Are you trying it won’t spamming print?
if yes @gokkertje566 , brought the code fix

local part = script.Parent

part.Touched:Connect(function(hi)
	local p = hi and hi.Parent:FindFirstChildWhichIsA("Humanoid")
	
	if p then
		p.WalkSpeed = 100
	end
end)

part.TouchEnded:Connect(function(hi)
	local p = hi and hi.Parent:FindFirstChildWhichIsA("Humanoid")

	if p then
		p.WalkSpeed = 16
	end
end)

Server script in the part

let me test your code, i think it has sum to do with the getplr but idk

This code works 100% as i tried it

tysm your code works! i think the getplr event was just acting funny!

No bro.
You dont need get plr or stuff like that.

yh ik, the thing is i had to use it to fix other peices of code where it did work but i think i mighta overused it lol

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.