Someone please help?

So i made a radio and a gui. In the gui i have a button and i want when i press it to change my radio skin. I already scripted this but does not work. Some help?

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
script.Parent.MouseButton1Click:connect(function()
local plr = game.Workspace:WaitForChild(player.Name)
plr.Radio:destroy()
end)
end)
end)

1 Like

also i used destroy() to test if it works but does not even destroy the radio from my back

Is this code in a LocalScript? Also, where are the gui and script located?

Yes its in a LocalScript. the gui goes into the PlayerGui when the radio is equiped

you can do .LocalPlayer instead of the way you’ve done it.
Don’t believe .PlayerAdded events fire within local scripts.

I want the skin to be visible to everyone

Alright let me rewrite this for you.

In the LocalScript:

local remote = game.ReplicatedStorage.ChangeSkin --put a RemoteEvent called "ChangeSkin" in ReplicatedStorage

script.Parent.MouseButton1Click:Connect(function()
    remote:FireServer()
end)

In a regular Script in ServerScriptService:

game.ReplicatedStorage.ChangeSkin.OnServerEvent:Connect(function(player)
    player.Character.Radio:Destroy()
end)
1 Like

Thanks!!

I don’t get why you have used a player added function in a local script. Also if you were to change skin from a local script it would only show for the player who has the radio on, you must use a remote event to transfer it to server side.

No problem.

I know. It wasn’t me the person who wrote it. It was my brother. Anyways thanks for helping him out guys.

For future reference, you should probably use a more descriptive title.

2 Likes