So, every time a player joins the game, a StringValue will be added to their player, to hold the ability that they equipped. The default ability is set to “Cheezburger” when they join the game, and it will change according to the ability they equip. Once the round starts, another script is supposed to run through the players to find the StringValue and clone the item into their backpack from ReplicatedStorage accordingly, but for some reason no matter what ability I equipped, the script always gives me Cheezburger. Why does this happen?
-- Some variables are for other parts of the script, this is the part that clones the ability
local playingTeam = game.Teams.Playing
local timeLeft = game.ReplicatedStorage.Values.Countdown
local roundInProgress = game.ReplicatedStorage.Values.RoundInProgress
local diedEvent = game.ReplicatedStorage.Events.PlayerDied
local countdown = game.ReplicatedStorage.Values.Countdown
local Players = game.Players
local abilities = game:GetService("ReplicatedStorage").Items:GetChildren()
local function ProvideAbility()
for i, player in playingTeam:GetPlayers() do
local currentAbility = player:WaitForChild("Ability")
print(currentAbility.Value)
for _, ability in abilities do
if ability.Name == currentAbility.Value then
local clonedAbility = ability:Clone()
clonedAbility.Parent = player.Backpack
end
end
end
task.cancel(abilityTask)
end
roundInProgress:GetPropertyChangedSignal("Value"):Connect(function()
if roundInProgress.Value == true then
potatoTask = task.spawn(TagRandomPlayer)
abilityTask = task.spawn(ProvideAbility)
end
end)
-- Some things in the script may not look good, I am not very good at scripting ;)