Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Script doesn't activate if already activated by another player?

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)

2 answers

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.

2 comments

0

Ok. I already did so I edited it

0

Can you show the rest of the script then?

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.