script.Parent.Touched:Connect(function(hit) local b = hit.Parent:FindFirstChild("Humanoid") if b ~= nil then wait() print("True / Humanoid Hit") if b.WalkSpeed > 30 then wait() script.Parent.Anchored = false print("True / Destroyed Part") end end end)
YES the walk speed was at superior of 30
When i touch the part the output say that ( True / Humanoid hit ) but it not showing the other print and it not unanchor the part
The WalkSpeed
property of Humanoid
is not replicated across the server and client. This means that the server will read the walkspeed as 16, unless it is set from the server.
We can use a RemoteFunction
to get around this. Since RFs can return values, we will use it to return the player's walkspeed.
-- place this in startergui (localscript) -- create a remotefunction in replicatedstorage -- name it "GetHealth" local function health() return game.Players.LocalPlayer.Character.Humanoid.WalkSpeed end game.ReplicatedStorage.GetHealth.OnClientInvoke = health
Edited code:
script.Parent.Touched:Connect(function(hit) local b = hit.Parent:FindFirstChild("Humanoid") if b ~= nil then wait() local plr = game.Players:GetPlayerFromCharacter(hit.Parent) local speed = game.ReplicatedStorage.GetHealth:InvokeClient(plr) print("True / Humanoid Hit") if speed > 30 then wait() script.Parent.Anchored = false print("True / Destroyed Part") end end end)