Im trying to make the player’s screen flash for a moment when they touch the object shown in the video. However, for SOME reason, the game freezes for a good second after the object is destroyed. I’ve genuinely tried everything, but i still can’t figure out how to fix this. I’ve tried making the object transparent instead of outright destroying it, and that seemed to KINDA fix the issue, but the flash still came onto the screen with a delay.
Server:
local debounce = false
task.spawn(function()
while task.wait(0.15) do
script.Parent.CFrame *= CFrame.Angles(0, math.rad(20), 0)
end
end)
script.Parent.Touched:Once(function(p)
if debounce == false and p.Parent:FindFirstChild("Humanoid") then
debounce = true
script.Parent:Destroy()
game.ReplicatedStorage.Flash:FireAllClients()
end
end)
Client:
local event = game.ReplicatedStorage:WaitForChild("Flash")
event.OnClientEvent:Connect(function()
local player = game.Players.LocalPlayer
local vig = player.PlayerGui.Vignette
vig.ImageLabel.ImageTransparency = 0.2
game.TweenService:Create(vig.ImageLabel, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.In), {ImageTransparency = 1, BackgroundTransparency = 1}):Play()
end)