Hello there guys!
I’m looking to make script that detect you standing on a part and not moving.
Lets say the player is standing on the part its printing his name.
Thanks!
local part = -- put your part path location here (for example: game.Workspace.PartName)
part.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
print(hit.Parent.Name)
end
end)
Easy, put this:
local part = script.Parent -- the part the player touches
local function Trigger(part)
local hum = part.Parent:FindFirstChild("Humanoid")
if hum then
print(hum.Name) -- if this doesn't work put hum.Parent.Name
end
part.Touched:Connect(Trigger)
Crud, @Citrozi already did it
1 Like
Detect player standing still and not moving
Replace my other script with this one
local part = -- put your part path location here (for example: game.Workspace.PartName)
part.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
local humanoid = hit.Parent:FindFirstChild("Humanoid")
wait(0.1)
if humanoid.MoveDirection.Magnitude == 0 then
print(hit.Parent.Name)
end
end
end)
1 Like
put this inside the part
local part = script.Parent
part.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum then
if hum.MoveDirection.Magnitude == Vector3.new(0,0,0) then
print("Player Is Standing Still!")
end
end
end)
local Game = game
local Workspace = workspace
local RunService = Game:GetService("RunService")
local Part = Workspace.Part
local function OnHeartbeat()
local Parts = Part:GetTouchingParts()
for _, Part in ipairs(Parts) do
local Model = Part:FindFirstAncestorOfClass("Model")
if not Model then continue end
local Humanoid = Model:FindFirstChildOfClass("Humanoid")
if not Humanoid then continue end
if Humanoid.MoveDirection.Magnitude ~= 0 then continue end
print(Model.Name)
end
end
RunService.Heartbeat:Connect(OnHeartbeat)
2 Likes