Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do you make a motion detector that shows a gui when detected motion?

Asked by 3 years ago

I've been trying to make games lately and they suck but I just had an idea but I don't know how to script it. Can anybody please help me?

1 answer

Log in to vote
0
Answered by 3 years ago
local chr = script.Parent -- Get character
local hum = chr:WaitForChild("Humanoid") -- Get humanoid
local plr = game.Players.LocalPlayer

while wait() do
    if hum.MoveDirection.Magnitude > 0 then -- Check for motion
        plr.PlayerGui.AWrfawf.Enabled = true -- change "AWrfawf" to the ScreenGUI's name
    else
        plr.PlayerGui.AWrfawf.Enabled = false -- change "AWrfawf" to the ScreenGUI's name
    end
end

Please remember to accept my answer!

0
Why do you need the while wait(), couldn't you just do the if statement and if Magnitude = 0 then Enabled = false? I feel like that'd be more performance efficient since its not constantly checking, but I'm not the best coder so... DUCKONAROLL 0 — 3y
0
Thanks! TheStageGuyYT 19 — 3y
0
Didn't work TheStageGuyYT 19 — 3y
Ad

Answer this question