I am working on a offroad car simulation game, I got everything working fine.
I changed the properties of the water so it looks like mud, but I cant get the detection to work.
I want it so if a player is stuck for 5 seconds in water there should popup a text on th player’s screen. But it does not work rn.
local timer = 0 local deb = false local Part = script.Parent Part.Touched:Connect(function() end) function CheckIfPlayerIsInArea(Part, Character) local touching = Part:GetTouchingParts() for i = 1,#touching do if touching[i] == Character.HumanoidRootPart then return true end end return false end script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then repeat if CheckIfPlayerIsInArea(Part, hit.Parent) == true then timer = timer + 1 else if timer <= 0 then timer = 0 else timer = timer - 1 end end wait(1) until timer >= 3 if timer >= 3 then -- Player is stuck print("Player is stuck") end end end)
Thanks in advance.