This is a LocalScript I made that makes a single player's screen fade white in and out when touching a part, and it works just fine, until another player goes in and activates the script themselves and now the script doesn't work for the next person. Can anybody find out what's up with it?
db = true function onTouch(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if db == true and humanoid ~= nil then db = false local player = game.Players:GetPlayerFromCharacter(hit.Parent) wait(0.01) player.PlayerGui.FadeGui.Frame.BackgroundTransparency = 0.9 -- rest of the otherwise perfectly fine code goes here wait(0.1) db = true end end workspace.Teleportation.BeginTeleport.Touched:Connect(onTouch)
You never defined 'db' as a variable. If you did earlier in the script and just didn't show us, you're probably going to need to show the entire script.
Solved it myself.
function onTouch(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if db == true and humanoid ~= nil then local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player.Name == plr.Name then db = false player.PlayerGui.FadeGui.Frame.BackgroundTransparency = 0.9 -- rest of code goes here wait (0.1) db = true end end end workspace.Teleportation.BeginTeleport.Touched:Connect(onTouch)