Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited 5 years ago

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

Log in to vote
0
Answered by 5 years ago

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.

0
Ok. I already did so I edited it DogeIsDohj 10 — 5y
0
Can you show the rest of the script then? DaBrainlessOne 129 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

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)

Answer this question