How is this script not working I have tried writing it in multiple different ways.
I have a tool named “Sword” in replicated storage and a folder created inside the player named “skin” with a intvalue inside named “skinequip”. I am trying to make it so that when it gives you the tool it changes the texture for you depending on the “skinequip” value. Here is the script. Any help appreciated
local RS = game:GetService("ReplicatedStorage")
local Tools = RS:FindFirstChild("Sword")
script.Parent.Touched:Connect(function(Hit)
local Player = game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent)
local Tool = Player.Backpack:FindFirstChild("Sword") or Player.Character:FindFirstChild("Sword")
if not Tool then
local clone = Tools:Clone()
clone.Handle.Mesh.TextureId.Value = Player.skin.skinequip.Value
clone.Parent = Player.Backpack
end
end)
I tried a different approach that seemed to work: instead of looking for the tool in replicated storage, I just made a script that I put in the tool that checks for when the tool is equipped. If the tool is equipped, change the texture of the mesh to skinequip.
local tool = script.Parent
tool.Equipped:Connect(function()
local char = tool.Parent
local player = game:GetService("Players"):GetPlayerFromCharacter(char)
local skinEquip = player.skin.skinequip
tool.Handle.Mesh.TextureId = skinEquip.Value
end)
I tried the script but there is a problem, even when an id is in the value it still just puts no texture and makes the sword all grey when you equip it. But there are no errors with the sword
Oh I assumed the texture was supposed to be grey. That is probably a problem with the texture not matching up with the sword mesh rather than something with the code then.
I figured it out, the value has to be a link instead of just the ID. Also the object that holds the value has to be a StringValue instead of an IntValue.
**Side note: don’t include the quotation marks when typing the link into the value