Trying to destroy a part based on walkspeed but it doesn't work

I want to destroy a block if the player’s walkspeed is above a certain amount. But when I tried to do this it didn’t work, can someone explain my problem?

local part = script.Parent

local function Touch(partTouched)
	local partparent = partTouched.Parent
	
	local humanoid = partparent:FindFirstChildWhichIsA("Humanoid")
	if humanoid then
		if humanoid.WalkSpeed >= 32 then
			print("yes")
			part:Destroy()
		end
	end
end

part.Touched:Connect(Touch)

This is done on a server script if that helps.

2 Likes

dont know what the problem is since i tried it and it works perfectly fine

1 Like

Can you screenshot your explorer with the relevant part and script?

image

if youre talking about what the script is in, this is it

is player speed more than 32? in server

1 Like

the thing increasing the player’s speed is in a local script so it could be?

Server won’t see anything that local script made

1 Like

It won’t be replicated to the server, even if they player is walking faster. The server will still think the player’s walk speed is the default. You could print this in your script to confirm. Try moving the walk speed change to a server script.

alright ill tell you if it works

I couldnt change it to a server script because the script that changes the speed required the user input. Instead I used a remote event which works perfectly fine.

sorry for how long it took for the reply.

I know im late but, mark the solution as a solution, that way people know this topic is solved

I would mark this as a solution:

Or this:

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