I tried to make an arrow script, that has an if statement. It checks if you have a folder with standsummon, and if you do it’ll do nothing. But if you don’t have a folder, with standsummon, then it’ll give you a folder of that sort. It doesn’t work. Even if the player has a folder of the sort, then it’ll still give you a stand. I don’t know how to fix it.
--// Arrow Script
local rp = game:GetService("ReplicatedStorage")
local Arrow = rp:WaitForChild("arrow")
Arrow.OnServerEvent:Connect(function(player, Arrow)
wait(1.5)
local Backpack = player:FindFirstChild("Backpack")
local randomStand = math.random(1,3) --1 to the number of stands you have
if Backpack then
if randomStand == 1 then
local Stands = game:GetService("ServerStorage"):WaitForChild("Stands")
--//If stand is summoned
local prevStand = workspace:FindFirstChild(player.Name.." Stand")
if prevStand then
prevStand:Destroy()
end
for i, v in pairs(Backpack:GetChildren()) do
if v:IsA("Folder") then
local StandSummon = v:FindFirstChild("StandSummon")
if StandSummon then
print("Has Stand")
elseif StandSummon == nil then
local Stand = Stands:FindFirstChild("Stand1"):Clone()
Stand.Parent = Backpack
local PlrStats = player:FindFirstChild("PlrStats")
if PlrStats then
local currentStand = PlrStats:FindFirstChild("Stand")
currentStand.Value = "Stand1"
end
end
end
end
elseif randomStand == 2 then
local Stands = game:GetService("ServerStorage"):WaitForChild("Stands")
--//If stand is summoned
local prevStand = workspace:FindFirstChild(player.Name.." Stand")
if prevStand then
prevStand:Destroy()
end
for i, v in pairs(Backpack:GetChildren()) do
if v:IsA("Folder") then
local StandSummon = v:FindFirstChild("StandSummon")
if StandSummon then
print("Has Stand")
elseif StandSummon == nil then
local Stand = Stands:FindFirstChild("Stand2"):Clone()
Stand.Parent = Backpack
local PlrStats = player:FindFirstChild("PlrStats")
if PlrStats then
local currentStand = PlrStats:FindFirstChild("Stand")
currentStand.Value = "Stand2"
end
end
end
end
elseif randomStand == 3 then
local Stands = game:GetService("ServerStorage"):WaitForChild("Stands")
--//If stand is summoned
local prevStand = workspace:FindFirstChild(player.Name.." Stand")
if prevStand then
prevStand:Destroy()
end
for i, v in pairs(Backpack:GetChildren()) do
if v:IsA("Folder") then
local StandSummon = v:FindFirstChild("StandSummon")
if StandSummon ~= nil then
print("Has Stand")
elseif StandSummon == nil then
local Stand = Stands:FindFirstChild("Stand3"):Clone()
Stand.Parent = Backpack
local PlrStats = player:FindFirstChild("PlrStats")
if PlrStats then
local currentStand = PlrStats:FindFirstChild("Stand")
currentStand.Value = "Stand3"
end
end
end
end
end
end
end)