How do I make Jetpack Skins show for All Players?

Hey everyone, I am having trouble with something. In my game you can equip jetpack skins using a GUI, everything works on the local side when you equip a skin but for other players when you equip a skin their jetpack just disappears, and I know its not completely local because the jetpack does atleast disappear for other players, how do I make the skin show for everyone? Here is my script,

local button = script.Parent
local players = game:GetService("Players")
local player = players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local skins = game:GetService("ReplicatedStorage"):WaitForChild("Skins")
local jetpack = char:WaitForChild("Jetpack")

local wins = player:WaitForChild("leaderstats"):WaitForChild("Wins")
local winsreq = script.Parent.Parent.Wins
local equipped = false

local debounce = false

button.MouseButton1Click:Connect(function(player)
	if debounce then return end
	debounce = true
	if wins.Value >= winsreq.Value then
		if equipped == false then
			
			local clone = skins.Goldpack.Jetpack:Clone()
			clone.Parent = jetpack
			clone.Name = "Clone"
			clone.Position = jetpack.Jetpack.Position
			clone.Orientation = jetpack.Jetpack.Orientation
			jetpack.Jetpack:Destroy()
			clone.Name = "Jetpack"
			local weld = Instance.new("WeldConstraint")
			weld.Parent = jetpack.Jetpack
			weld.Part0 = jetpack.Handle
			weld.Part1 = jetpack.Jetpack
			
			equipped = true
			
			button.Text = "Unequip"
		
	elseif equipped == true then
		
			local clone = skins.Jetpack.Jetpack:Clone()
			clone.Parent = jetpack
			clone.Name = "Clone"
			clone.Position = jetpack.Jetpack.Position
			clone.Orientation = jetpack.Jetpack.Orientation
			jetpack.Jetpack:Destroy()
			clone.Name = "Jetpack"
			local weld = Instance.new("WeldConstraint")
			weld.Parent = jetpack.Jetpack
			weld.Part0 = jetpack.Handle
			weld.Part1 = jetpack.Jetpack
		
		equipped = false
		
		button.Text = "Equip"
		
		end
		end
	wait(3)
	debounce = false
end)

It is a LocalScript located inside of a button in StarterGui.

Create a RemoteEvent that passes the jetpack skin over to the server. The server would do the function of placing the skin on the player so that the rest of the server can see it.

LocalScripts will only show for the client/the player it self and the starterGui gets copied in to every player so every player will only see his own skin you could solve this by making a normal script wich access the server instead of the clien.

Hey, I started it, it seems to work, im having trouble figuring out how to call for the skin using string values so I dont have to make an event for each skin, how would I do that?


Whenever you wanted to equip a skin from the client, you could pass the jetpack skin object over to the server

game:GetService("ReplicatedStorage").Import.OnServerEvent:Connect(function(player, jetpackSkin) --> Skin is the jetpack skin you want the server to see
     
     local char = player.Character or player.CharacterAdded:Wait()
     local skins = game:GetService("ReplicatedStorage"):WaitForChild("Skins")
     local jetpack = char:WaitForChild("jetpack")
     local skin = player:WaitForChild("leaderstats").Skin

     skin.Value = jetpackSkin.Name

     local clone = jetpackSkin:Clone()
     --> rest of your code
end)

You would make your code something like this.

I got this error, ServerScriptService.Import:8: attempt to index nil with ‘Name’ - Server - Import:8

image

Can I see your code for both the client and server? I might’ve made an error

Server:

game:GetService("ReplicatedStorage").Import.OnServerEvent:Connect(function(player, jetpackSkin) --> Skin is the jetpack skin you want the server to see
     wait(1)
     local char = player.Character or player.CharacterAdded:Wait()
     local skins = game:GetService("ReplicatedStorage"):WaitForChild("Skins")
     local jetpack = char:WaitForChild("Jetpack")
     local skin = player:WaitForChild("leaderstats").Skin

     skin.Value = jetpackSkin.Name

     local clone = jetpackSkin:Clone()
	clone.Parent = jetpack
	clone.Name = "Clone"
	clone.Position = jetpack.Jetpack.Position
	clone.Orientation = jetpack.Jetpack.Orientation
	jetpack.Jetpack:Destroy()
	clone.Name = "Jetpack"
	local weld = Instance.new("WeldConstraint")
	weld.Parent = jetpack.Jetpack
	weld.Part0 = jetpack.Handle
	weld.Part1 = jetpack.Jetpack
end)

Client:

local button = script.Parent
local players = game:GetService("Players")
local player = players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local skins = game:GetService("ReplicatedStorage"):WaitForChild("Skins")
local jetpack = char:WaitForChild("Jetpack")
local skin = player:WaitForChild("leaderstats").Skin
local rs = game:GetService("ReplicatedStorage")
local event = rs:WaitForChild("Import")

local wins = player:WaitForChild("leaderstats"):WaitForChild("Wins")
local winsreq = script.Parent.Parent.Wins
local equipped = false

local debounce = false

button.MouseButton1Click:Connect(function(player)
	if debounce then return end
	debounce = true
	if wins.Value >= winsreq.Value then
		if equipped == false then
			
			skin.Value = "Goldpack"
			
			event:FireServer()
			
			equipped = true
			
			button.Text = "Unequip"
		
		elseif equipped == true then
			
			skin.Value = "Jetpack"
		
			event:FireServer()
		
		equipped = false
		
		button.Text = "Equip"
		
		end
		end
	wait(3)
	debounce = false
end)

You’re not passing the skin object, so your server script is saying .Name is nil since jetpackSkin is nil

if equipped == false then
			
			skin.Value = "Goldpack"
			local jetpackSkin = skin

			event:FireServer(jetpackSkin)
			
			equipped = true
			
			button.Text = "Unequip"

Would I do something like this?

Yeah. Also, you wouldn’t need to set the skin.Value on the client script since it won’t appear on the server leaderstats.

You could do it on the server when you send the skin object to the server.

Wouldn’t that defeat the purpose of avoiding having to make a remote event for each skin? Because there are about 6, and I want to be able to use one event for all of them.

Also after I did that it said

Position is not a valid member of StringValue "Workspace.spideyvhs.Jetpack.Clone"  -  Server - Import:13

How do I make it get the Mesh and not the string value?

You would look for the skin object in the skins folder you have in ReplicatedStorage by using FindFirstChild on the folder and putting in the skin name in the parameter.

On the client:

local jetpackObject = skins:FindFirstChild(skin.Value)

event:FireServer(jetpackObject)

1 Like

Thank you, I made sure to change the skin value and then I added this and everything is working.

image
image

Thanks so much!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.