Pro_OLD31
(nubik)
November 3, 2024, 4:04pm
#1
I want to create a skin system for swords. I created a button that should change the texture of the sword when pressed.
This certainly works, but the texture will change only if I have the nickname Pro_OLD31, what should I write instead of “Pro_OLD31” so that every player can change the skin.
script.Parent.MouseButton1Click:Connect(function()
game.Players.Pro_OLD31.Backpack.Sword.Handle.Mesh.TextureId = "rbxassetid://129239835607605"
end)
I tried to search for an answer on the forum, but I did not find the right one.
thank you in advance
2 Likes
Do you want the skin to be visible by every player or just locally?
Pro_OLD31
(nubik)
November 3, 2024, 4:18pm
#3
The skin should be visible to every player, I made a regular script and not a local one.
Create a LocalScript inside the button :
script.Parent.Activated:Connect(function()
game.ReplicatedStorage.ChangeSkin:FireServer("rbxassetid://129239835607605")
end)
Create a server script inside ServerScriptService :
game.ReplicatedStorage.ChangeSkin.OnServerEvent:Connect(function(player, skinID)
local sword = player.Backpack:FindFirstChild("Sword") or player.Character:FindFirstChild("Sword")
sword.Handle.Mesh.TextureId = skinID
end)
And then create a RemoteEvent inside ReplicatedStorage and then name it “ChangeSkin”
Keep in mind that this code will allow players to use any skin they want
1 Like
Pro_OLD31
(nubik)
November 3, 2024, 6:04pm
#6
Thanks, but how do I make the skin persist after a reset or exit?
aerowrap
(aero)
November 3, 2024, 6:15pm
#7
Just store the sword inside StarterGear
when the skin gets changed. Once the player resets, it will put the sword from StarterGear
into Backpack
with the skin applied.
1 Like
Pro_OLD31
(nubik)
November 3, 2024, 6:39pm
#8
Could you describe in more detail how to add a sword to Starter Gear?
aerowrap
(aero)
November 3, 2024, 6:41pm
#9
sword:Clone().Parent = player.StarterGear
Pro_OLD31
(nubik)
November 3, 2024, 6:51pm
#10
This works, but then a second sword appears on reset, one with a skin and the other without.
aerowrap
(aero)
November 3, 2024, 6:54pm
#11
You’ll have to remove that sword without the skin since you have a sword without a skin in StarterPack
which replicates to the player’s Backpack
.
Having it persist after a server shutdown or game exit requires using datastores.Those are pretty advanced, definitely not beginner friendly.
system
(system)
Closed
November 17, 2024, 7:05pm
#13
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.