Anybody knows where is the issue on my script? The Decal are always showed up a white screen everytime I want to trigger the jumpscare before it showed up (sometimes)
This would be the script:
local debounce = false
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') and not debounce then
debounce = true
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then
humanoid.Health = 0 -- Kill the player
wait(0.1) -- Wait for a brief moment before triggering jumpscare
local playerGui = player:FindFirstChild("PlayerGui")
if playerGui then
local jumpscareGUI = playerGui:FindFirstChild("Jumpscare")
if jumpscareGUI then
-- Delay the enabling of the jumpscare GUI by a short period
wait(0.1)
jumpscareGUI.Enabled = true
wait(2)
jumpscareGUI.Enabled = false -- Corrected line to disable the jumpscare GUI
end
end
end
end
debounce = false -- Reset the debounce flag after the wait period
end
end)