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 6 years ago
Edited 6 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?

01db = true
02function onTouch(hit)
03    local humanoid = hit.Parent:FindFirstChild("Humanoid")
04    if db == true and humanoid ~= nil then
05        db = false
06        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
07        wait(0.01)
08        player.PlayerGui.FadeGui.Frame.BackgroundTransparency = 0.9
09        -- rest of the otherwise perfectly fine code goes here
10        wait(0.1)
11        db = true
12        end
13    end
14workspace.Teleportation.BeginTeleport.Touched:Connect(onTouch)

2 answers

Log in to vote
0
Answered by 6 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 — 6y
0
Can you show the rest of the script then? DaBrainlessOne 129 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

Solved it myself.

01function onTouch(hit)
02    local humanoid = hit.Parent:FindFirstChild("Humanoid")
03    if db == true and humanoid ~= nil then
04    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
05    if player.Name == plr.Name then
06        db = false
07        player.PlayerGui.FadeGui.Frame.BackgroundTransparency = 0.9
08        -- rest of code goes here
09        wait (0.1)
10        db = true
11end
12end
13end
14workspace.Teleportation.BeginTeleport.Touched:Connect(onTouch)

Answer this question