How to make a suffocation effect

Is it possible to make a suffocation effect in roblox?

Basically what I mean is if you are in a specific area of the map, how can you check if a player has been standing still for like 10 seconds and then it plays an animation of an image that swirls around and becomes more and more visible the longer you idle?

2 Likes

You could make a part that acts like a zone and script it so if the player stays in it for over 10 seconds it does the effect.

The effect can be done using TweenService by simply tweening the image’s rotation around.

For the actual zone detection, I’d use Magnitude.

local part = --The part.

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        while task.wait(0.1) do
            print((character.HumanoidRootPart.CFrame.Position-part.CFrame.Position).Magnitude)
        end
    end)
end)

This only makes a circular distance, so if your hitbox is designed to be a square, then this wouldn’t work properly.

I’ve made a script that does roughly what you’re asking for ( i haven’t tested it so i’m not sure if there is any errors)

local TweenService = game:GetService("TweenService")
local player = game:GetService("Players").LocalPlayer
local humanoid = player.Character.Humanoid
local Timer = 0
local TweenIsPlaying = false
local ImageTween = TweenService:Create()--Creat the tween here
humanoid.Running:Connect(function(speed)
	if speed > 0 then
		Timer = 0
		if TweenIsPlaying then
			ImageTween:Cancel()
		end
	end
	
end)

while wait(1) do
	Timer +=1
	if Timer == 10 then
		ImageTween:Play()
		TweenIsPlaying = true
		ImageTween.Completed:Connect(function()
			--Do something when the image is fully visible
			TweenIsPlaying = false
		end)
	end
end

So basically what i do here is i have a loop that increments a timer every second, but if the player moves it resets the timer. If however the timer reaches 10 then it starts the Tween of the swirling image.
Now lets assume the image starts slowly appear but you move, you will then cancel that and go back to normal. Only when the image fully appears that the action happens( you die or something) OR if you want nothing to happen to the player don’t add anything ^^
Hope this helps hit me back if there are any errors

2 Likes

Thank you so much! This worked very well and was exactly what I was looking for, Just needed to make some edits and it worked as intended! Appreciated!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.