SOLVED! Thank you everyone!
line 12: game.Players.PlayerAdded:Connect(function(player)
This event should not be inside of a loop as it will not fire during runtime. What you can do it do something like…
game.Players.PlayerAdded:Connect(function(player)
for _, v in pairs (DF:GetChildren()) do
-- more of that code
You want the event to wrap the loop, not the loop wrapping the event.
Why does v.Name
have an error.(the red line under v)? Is that piece of code no longer inside the for loop?
I really don’t know, here is the current updated script
Seems like you are giving the player as many swords as the number of doors in the room. Am I right?
Ah, I see now. Here’s a fix:
local plr = game.Players:GetPlayerFromCharacter(Enter.Parent) -- Creating a varible for the player by using there character
local bp = plr.Backpack -- Creating a varible for the players backpack
local sw = game.ReplicatedStorage.LinkedSword:Clone() -- Creating a varible of the sword and cloning it
local swB = game.ReplicatedStorage.Windforce:Clone()
local swS = game.ReplicatedStorage.Ghostwalker:Clone()
local swG = game.ReplicatedStorage.Darkheart:Clone()
local swP = game.ReplicatedStorage.Illumina:Clone()
if bp:FindFirstChild("LinkedSword") == nil and bp:FindFirstChild("Windforce") == nil and bp:FindFirstChild("Ghostwalker") == nil and bp:FindFirstChild("Darkheart") == nil and bp:FindFirstChild("Illumina") == nil and mps:UserOwnsGamePassAsync(player.UserId, gamepass_plat) and Enter.Parent:FindFirstChild("Illumina") == nil then -- Attempting to find sword
swP.Parent = bp -- Placing cloned sword if we cant find sword
elseif bp:FindFirstChild("LinkedSword") == nil and bp:FindFirstChild("Windforce") == nil and bp:FindFirstChild("Ghostwalker") == nil and bp:FindFirstChild("Darkheart") == nil and bp:FindFirstChild("Illumina") == nil and mps:UserOwnsGamePassAsync(player.UserId, gamepass_gold) and Enter.Parent:FindFirstChild("Darkheart") == nil then -- Attempting to find sword
swG.Parent = bp -- Placing cloned sword if we cant find sword
elseif bp:FindFirstChild("LinkedSword") == nil and bp:FindFirstChild("Windforce") == nil and bp:FindFirstChild("Ghostwalker") == nil and bp:FindFirstChild("Darkheart") == nil and bp:FindFirstChild("Illumina") == nil and mps:UserOwnsGamePassAsync(player.UserId, gamepass_silver)and Enter.Parent:FindFirstChild("Ghostwalker") == nil then -- Attempting to find sword
swS.Parent = bp -- Placing cloned sword if we cant find sword
elseif bp:FindFirstChild("LinkedSword") == nil and bp:FindFirstChild("Windforce") == nil and bp:FindFirstChild("Ghostwalker") == nil and bp:FindFirstChild("Darkheart") == nil and bp:FindFirstChild("Illumina") == nil and mps:UserOwnsGamePassAsync(player.UserId, gamepass_bronze) and Enter.Parent:FindFirstChild("Windforce" ) == nil then -- Attempting to find sword
swB.Parent = bp -- Placing cloned sword if we cant find sword
else sw.Parent = bp -- Placing cloned sword if we cant find sword
end --
end --
end)
end --
end --
if v.Name == "ArenaLeave" then -- Same as above execpt the name is ArenaLeave not ArenaEnter
v.Touched:connect(function(Leave) -- We are checking to see if V was touched and making sure we spell touched right... Yep I wrote it again
if Leave.Parent:FindFirstChild("Humanoid") then-- Checking to see if what touched V has a humanoid in its parent(still weird)
local plr = game.Players:GetPlayerFromCharacter(Leave.Parent) --Creating a varible for the player by using there character
local bp = plr.Backpack -- Creating a varible for the players backpack
if bp:FindFirstChild("LinkedSword") ~= nil and bp:FindFirstChild("Windforce") ~= nil and bp:FindFirstChild("Ghostwalker") ~= nil and bp:FindFirstChild("Darkheart") ~= nil and bp:FindFirstChild("Illumina") ~= nil then -- Checking for sword in the BP varible
bp.LinkedSword:Destroy() -- Destroying the sword like the guests I used to kill...
bp.Windforce:Destroy()
bp.Ghostwalker:Destroy()
bp.Darkheart:Destroy()
bp.Illumina:Destroy()
end --
if Leave.Parent:FindFirstChild("LinkedSword") ~= nil and Leave.Parent:FindFirstChild("Windforce") ~= nil and Leave.Parent:FindFirstChild("Ghostwalker") ~= nil and Leave.Parent:FindFirstChild("Darkheart") ~= nil and Leave.Parent:FindFirstChild("Illumina") ~= nil then -- Checking for that pesky sword again
Leave.Parent.LinkedSword:Destroy()
Leave.Parent.Windforce:Destroy()
Leave.Parent.Ghostwalker:Destroy()
Leave.Parent.Darkheart:Destroy()
Leave.Parent.Illumina:Destroy() --
end --
end --
end) --
end --
end) --
I don’t know what I am doing wrong but sadly now it gives me no sword
Might me due to the ArenaExit v.Name not working
Yeah, your error is buried deep down somewhere. It’s up to you know
Solved! thanks guys!
Try this code.
I believe that your error was that you did not have the code block for if v.Name == "ArenaLeave" then
inside of the for loop. When I deleted the end --
on line 35 of your code (I believe this line), the error for any v.Name or v.Touched disappeared. That doesn’t mean your code works, I was mostly trying to get rid of that error so make sure to test it.