Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer
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!

3 comments

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...

0

Thanks!

0

Didn't work

This discussion is preserved as it was. New answers, comments, and votes are closed.