Hey Developers,
I have been watching this new Netflix series called “Squid Game” I’ve seen some Roblox games that managed to recreate it.
I was wondering how I would go about detecting if a player is walking or jumping when the red light is called I’ve had a few ideas in mind such as values but that just seems messy.
Is anybody able to help me out?
1 Like
You can use Humanoid:GetState() to check what they are currently doing and then set their health to 0 if they are moving.
3 Likes
I would check the velocity of the HumanoidRootPart on the character models then kill the player if they exceed whatever number.
1 Like
What I would do is put all the players’ root parts on a list and check if the root part moves, you just place what you want to happen if they do. Like so;
local players = {} -- list of all the players that are "players"
for i,v in pairs(players) do
local character = player.Character or player.CharacterAdded
if character ~= nil then
local rootpart = character:WaitForChild("HumanoidRootPart")
local oldpos = rootpart.Position
rootpart:GetPropertyChangedSignal("Position"):Connect(function()
local newpos = rootpart.Position
-- do what you want here...
oldpos = newpos
end)
end
end
1 Like
Well, I hope this is a guide. This is a pseudo code it means that it is untested. If there’s a typo then you might wanna correct it.
-- Insert on ServerScriptService
function onRedLight(humanoid)
humanoid.Running:Connect(function()
humanoid.Health = 0
end)
humanoid.StateChanged:Connect(function(oldState, newState)
if newState == Enum.HumanoidStateType.Jumping then
humanoid.Health = 0
if humanoid:GetState() == Enum.HumanoidStateType.Freefall then
humanoid.Health = 0
end
end
end)
end
function onGreenLight()
-- do stuff for the green light.
end
local RemoteEvent1 = pathto.RemoteEvent
local RemoteEvent2 = pathto.RemoteEvent
local players = game.Players:GetChildren()
local character
local humanoid
for _, plr in pairs(players) do
character = plr.Character or plr.CharacterAdded:Wait()
humanoid = character:WaitForChild("Humanoid")
end
-- Remote Event that starts the Red Light mode.
RemoteEvent1.OnServerEvent:Connect(function()
onRedLight(humanoid)
end)
-- Remote Event that starts the Green Light mode.
RemoteEvent2.OnServerEvent:Connect(function()
onGreenLight()
end)
1 Like
To see if they are walking, you can use this boolean statement: if Player.Character.Humanoid.MoveDirection.Magnitude > 0 then (do code) end
1 Like
Thank you so much everybody for the feedback, I will look into all the options below!!
1 Like