local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
print(player.Name .. " joined the game!")
local winners = {35782912} -- 35782912
if table.find(winners,player.UserId)then
print("yay"..player.Name)
local trophy = script:WaitForChild("Trophy"):Clone()
trophy.Parent = player:WaitForChild("Backpack")
print("I work")
end
end)
There aren’t any errors, and all the prints work, the trophy is just not showing up in the player’s backpack. I tried adding WaitForChilds to see if that would resolve the issue, but it’s still broken.
local Players = game:GetService("Players")
local winners = {35782912} -- 35782912
local trophy = script:WaitForChild("Trophy")
Players.PlayerAdded:Connect(function(player)
print(player.Name .. " joined the game!")
if table.find(winners,player.UserId)then
print("yay"..player.Name)
trophy:Clone().Parent = player.Backpack
print("I work")
end
end)
Yea, I’ve already tried that, it was originally that, but I changed it to see if WaitForChild would fix it. I actually decided to test just the clone part, without the table find part, and for some reason, I think the clone command is the issue, because it isn’t running.
Maybe try to put the Trophy tool somewhere else like ReplicatedStorage and try again? It could be the location of it that’s causing it
I would recommend doing this as well with moving it into ReplicatedStorage
local Players = game:GetService("Players")
local winners = {35782912} -- 35782912
local trophy = game.ReplicatedStorage:WaitForChild("Trophy")
Players.PlayerAdded:Connect(function(player)
print(player.Name .. " joined the game!")
player.CharacterAdded:Wait()
if table.find(winners,player.UserId)then
print("yay"..player.Name)
trophy:Clone().Parent = player.Backpack
trophy:Clone().Parent = player.StarterGear
print("I work")
end
end)
So it gives the tools in StarterGear and Backpack so you don’t have to give it everytime the player respawns
Could it be a possibility that it clones even though the character isn’t fully loaded? Try using a CharacterAdded event under PlayerAdded and above table.find
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
if table.find(winners,player.UserId) then
-- Stuff
end
end)
end)
local Players = game:GetService("Players")
local winners = {35782912} -- 35782912
local trophy = script:WaitForChild("Trophy")
Players.PlayerAdded:Connect(function(player)
print(player.Name .. " joined the game!")
if table.find(winners,player.UserId)then
print("yay"..player.Name)
local PlrChar=player.Character or player.CharacterAdded:wait()
local NewTrophy=trophy:Clone()
NewTrophy.Parent = player:WaitForChild("Backpack")
print("I work")
end
end)
I actually tried adding that, but it didn’t work out either, this is the script with CharacterAdded
local Players = game:GetService("Players")
local winners = {35782912} -- 35782912
local trophy = script:WaitForChild("Trophy")
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
print(player.Name .. " joined the game!")
if table.find(winners,player.UserId)then
print("yay"..player.Name)
trophy:Clone().Parent = player.Backpack
print("I work")
end
end)
end)
I second this comment. Had a problem that involved using ServerStorage when trying to replicate a model to a player (Welding body Armor), and moving the armor folder to ReplicatedStorage solved this problem. As the tool is a child of the Script, when the script runs, it may be causing the tool to become nil.
I recommend changing the location of the Trophy to ReplicatedStorage. As it will be a CLONED tool, therefor replicated.