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?
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
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!