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?
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)
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)
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.
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)