I tried Printing the weapons name and playing around with print() and so far printing works its just Clone() that doesnt work
local Rep = game.ReplicatedStorage
local SerS = game.ServerStorage
local Weapons = SerS["Weapons/Armors"]
local EquippedWep = Rep.PlayerData
script.Parent.Activated:Connect(function(Character)
--local WeaponName = Rep.PlayerData:FindFirstChild(Character.Name).Weapon.Value
local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
local WeaponName = Rep.PlayerData[player.Name].PrimaryWeapon.Value
local Weapon = game.ServerStorage["Weapons/Armors"]:FindFirstChild(WeaponName)
local e = SerS["Weapons/Armors"]:FindFirstChild(WeaponName):Clone()
print(e.Name)
e.Parent = player:FindFirstChild("Backpack")
if player then
game.ReplicatedStorage.PlayerData[player.Name].PrimaryWeapon.Value = "LongSword"
script.Parent:Destroy()
end
end)
if you have any questions about the system let me know I might be able to answer
Change it to FindFirstChild(WeaponName, true) and that should fix it, The problem is you are looking in the Weapons/Armor folder not the Weapon folder that the weapons are in
Replace :FindFirstChild(WeaponName) to .Weapon, if it’s not working, do :WaitForChild("Weapon").
This is how your script should be:
local Rep = game.ReplicatedStorage
local SerS = game.ServerStorage
local Weapons = SerS["Weapons/Armors"]
local EquippedWep = Rep.PlayerData
script.Parent.Activated:Connect(function(Character)
--local WeaponName = Rep.PlayerData:FindFirstChild(Character.Name).Weapon.Value
local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
local WeaponName = Rep.PlayerData[player.Name].PrimaryWeapon.Value
local Weapon = game.ServerStorage["Weapons/Armors"]:FindFirstChild(WeaponName)
local e = SerS["Weapons/Armors"].Weapon
e:Clone()
print(e.Name)
e.Parent = player:FindFirstChild("Backpack")
if player then
game.ReplicatedStorage.PlayerData[player.Name].PrimaryWeapon.Value = "LongSword"
script.Parent:Destroy()
end
end)
Yes, there’s some unlisted things about-in the script.
I think.
If it’s not working, consider doing :WaitForChild instead of .
local Rep = game.ReplicatedStorage
local SerS = game.ServerStorage
local Weapons = SerS["Weapons/Armors"]
local EquippedWep = Rep.PlayerData
script.Parent.Activated:Connect(function(Character)
--local WeaponName = Rep.PlayerData:FindFirstChild(Character.Name).Weapon.Value
local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
local WeaponName = Rep.PlayerData[player.Name].PrimaryWeapon.Value
local Weapon = game.ServerStorage["Weapons/Armors"]:FindFirstChild(WeaponName)
local e = SerS["Weapons/Armors"]:WaitForChild("Weapon")
e:Clone()
print(e.Name)
e.Parent = player:FindFirstChild("Backpack")
if player then
game.ReplicatedStorage.PlayerData[player.Name].PrimaryWeapon.Value = "LongSword"
script.Parent:Destroy()
end
end)
I have no clue if that works cause when I inserted that script and Clicked/Activated the tool nothing happened, I inserted lots of prints and none of those prints got printed
the system is bit hard to explain but in short:
Weapon tool is just 1 tool it changes stats/appearance based on PrimaryWeapon.Value (stringValue) this is located in Replicated Storage each player has his/her own PlayerData.
This tool I am trying to make already works, Only problem it does not give the weapon back after using it (I know I can remove the script.Parent:Destroy() part but I don’t want to)
you’re trying to find the weapon name in the weapons/armors folder but theres a secondary folder inside weapons/armors you’re not accessing, which is the one with the actual weapon in.
local Weapon = game.ServerStorage["Weapons/Armors"].Weapon:FindFirstChild(WeaponName)
This Tool first Goes Tries to Find PlayersData then looks for PrimaryWeapon.Value. after the script finds it, it goes inside ServerStorage["Weapons/Armors"].Weapons then looks for primaryweapon value (in this folder the value/name is a tool) clones it (there is a tool variant of the weapon) and then it sets cloned tools parent to players backpack
but this script doesn’t work and that’s why I am here
local Rep = game.ReplicatedStorage
local SerS = game.ServerStorage
local Weapons = SerS["Weapons/Armors"]
local EquippedWep = Rep.PlayerData
script.Parent.Activated:Connect(function(Character)
local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
local WeaponName = Rep.PlayerData[player.Name].PrimaryWeapon.Value
local Weapon = game.ServerStorage["Weapons/Armors"].Weapon:FindFirstChild(WeaponName)
local e = SerS["Weapons/Armors"]:FindFirstChild(WeaponName):Clone()
print(e.Name)
e.Parent = player:FindFirstChild("Backpack")
if player then
game.ReplicatedStorage.PlayerData[player.Name].PrimaryWeapon.Value = "LongSword"
script.Parent:Destroy()
end
end)
local Rep = game.ReplicatedStorage
local SerS = game.ServerStorage
local Weapons = SerS["Weapons/Armors"]
local EquippedWep = Rep.PlayerData
script.Parent.Activated:Connect(function(Character)
--local WeaponName = Rep.PlayerData:FindFirstChild(Character.Name).Weapon.Value
local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
local WeaponName = Rep.PlayerData[player.Name].PrimaryWeapon.Value
local Weapon = game.ServerStorage["Weapons/Armors"].Weapon:FindFirstChild(WeaponName)
local e = SerS["Weapons/Armors"].Weapon:FindFirstChild(WeaponName):Clone()
print(e.Name)
e.Parent = player:FindFirstChild("Backpack")
if player then
game.ReplicatedStorage.PlayerData[player.Name].PrimaryWeapon.Value = "LongSword"
script.Parent:Destroy()
end
end)
local Rep = game.ReplicatedStorage
local SerS = game.ServerStorage
local Weapons = SerS["Weapons/Armors"]
local EquippedWep = Rep.PlayerData
script.Parent.Activated:Connect(function(Character)
--local WeaponName = Rep.PlayerData:FindFirstChild(Character.Name).Weapon.Value
local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
local WeaponName = Rep.PlayerData[player.Name].PrimaryWeapon
local Weapon = game.ServerStorage["Weapons/Armors"].Weapon:FindFirstChild(WeaponName.Value)
local e = SerS["Weapons/Armors"].Weapon:FindFirstChild(WeaponName.Value):Clone()
print(e.Name)
e.Parent = player:FindFirstChild("Backpack")
if player then
game.ReplicatedStorage.PlayerData[player.Name].PrimaryWeapon.Value = "LongSword"
script.Parent:Destroy()
end
end)
the issue was
local WeaponName = Rep.PlayerData[player.Name].PrimaryWeapon.Value
I removed value part and wrote .Value next to every WeaponName inside the script
(If anybody knows how this worked please let me know)