-
What do you want to achieve? Keep it simple and clear!
I want to clone tools from the replicated storage to the backpack by confirming the name with an object value in leaderstats. -
What is the issue? Include screenshots / videos if possible!
When I test the game, I get no errors, however, the tools that were meant to be duplicated because of the object value in players are not in my backpack. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have spent weeks surfing the web for a solution, but it seems not many people are using an object value in players to clone the children of a part.
This is my script.
First, the player clicks on a button called spin, which then puts an object value into leaderstats .
The script below is meant to identify that objectvalue and if the name is identical to the name of a tool in replicated storage that tool is then cloned into the player’s backpack.
Im new to scripting and the output doesn’t say that there is an error , so im stuck on what to do.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Elements = ReplicatedStorage:FindFirstChild("Elements")
--Fire--
-- This part of the script will give a tool to a player when they respawn.
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Leaderstats = Player.Character.leaderstats.Inventory
local MagicSkills = Elements.Fire:GetChildren()
if Leaderstats.ObjectValue.Name == ("Fire") then
MagicSkills:Clone().Parent = Player.Backpack
end
end)
end)
------------------------------------------------------------------------------------------------------------------------
--Earth--
-- This part of the script will give a tool to a player when they respawn.
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Leaderstats = Player.Character.leaderstats.Inventory
local MagicSkills = Elements.Earth:GetChildren()
if Leaderstats.ObjectValue.Name == ("Earth") then
MagicSkills:Clone().Parent = Player.Backpack
end
end)
end)
-----------------------------------------------------------------------------------------------------------------------
--Wind--
-- This part of the script will give a tool to a player when they respawn.
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Leaderstats = Player.Character.leaderstats.Inventory
local MagicSkills = Elements.Wind:GetChildren()
if Leaderstats.ObjectValue.Name == ("Wind") then
MagicSkills:Clone().Parent = Player.Backpack
end
end)
end)
------------------------------------------------------------------------------------------------------------------------
--Lightning--
-- This part of the script will give a tool to a player when they respawn.
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Leaderstats = Player.Character.leaderstats.Inventory
local MagicSkills = Elements.Lightning:GetChildren()
if Leaderstats.ObjectValue.Name == ("Lightning") then
MagicSkills:CLone().Parent = Player.Backpack
end
end)
end)
------------------------------------------------------------------------------------------------------------------------
--Water--
-- This part of the script will give a tool to a player when they respawn.
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Leaderstats = Player.Character.leaderstats.Inventory
local MagicSkills = Elements.Water:GetChildren()
if Leaderstats.ObjectValue.Name == ("Water") then
MagicSkills:Clone().Parent = Player.Backpack
end
end)
end)
------------------------------------------------------------------------------------------------------------------------
--Ice--
-- This part of the script will give a tool to a player when they respawn.
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Leaderstats = Player.Character.leaderstats.Inventory
local MagicSkills = Elements.Ice:GetChildren()
if Leaderstats.ObjectValue.Name == ("Ice") then
MagicSkills:Clone().Parent = Player.Backpack
end
end)
end)
------------------------------------------------------------------------------------------------------------------------
--Sand--
-- This part of the script will give a tool to a player when they respawn.
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Leaderstats = Player.Character.leaderstats.Inventory
local MagicSkills = Elements.Sand:GetChildren()
if Leaderstats.ObjectValue.Name == ("Sand") then
MagicSkills:Clone().Parent = Player.Backpack
end
end)
end)
------------------------------------------------------------------------------------------------------------------------
--Light--
-- This part of the script will give a tool to a player when they respawn.
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Leaderstats = Player.Character.leaderstats.Inventory
local MagicSkills = Elements.Light:GetChildren()
if Leaderstats.ObjectValue.Name == ("Light") then
MagicSkills:Clone().Parent = Player.Backpack
end
end)
end)