I have a hit box in my game, and what it does is when a player touches it, it clones a local script that'll play a transition and then teleport the player in to a battle.
But to make sure it doesn't clone the local script multiple times, I made a blacklist. And basically the script is supposed to check if the player is in the blacklist, if they are then it returns. If they aren't then it adds them in and clones the local script into a screengui in the players backpack.
The blacklist isn't working and I keep getting the same error: "Attempt to index nil with PlayerGui". Here's my code:
Code
local blacklist = {};
script.Parent.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if (humanoid ~= nil) then
local Player = game.Players:GetPlayerFromCharacter(humanoid.Parent)
humanoid.Parent.Humanoid.WalkSpeed = -100
humanoid.Parent.Humanoid.JumpPower = -100
wait(1.20)
humanoid.Torso.CFrame = CFrame.new(-1475.4, 266.463, -612)
end
end)
local players = game:GetService("Players");
function foundInList(player) for _,target in ipairs(blacklist) do if target == player then return true; end end return false; end
script.Parent.Touched:connect(function(hit)
local player = players:GetPlayerFromCharacter(hit.Parent);
local ShowGUI = game.ServerStorage:FindFirstChild("ShowGUI4")
if ShowGUI ~= nil then
game.ReplicatedStorage.Events.BlackScreen4:FireAllClients()
ShowGUI.Parent = player.PlayerGui
end
end);

1 comment
Sorry about the code box not being right. I don't know how I can fix it.