How can I make a character shop?

ServerStorage is only accessible for ServerScripts. But any script can access to Workspace. As long as LocalScript cannot bypass themselves to the character, any way is ok!

1 Like

I scripted this, but it doesn’t work. Do you see any problem with the script? The output has one error saying "Character is not valid member of Players “Players”.

local character = game.Workspace.Dummy
local button = script.Parent
local player = game:GetService("Players")

function clicked()
	player.Character = character
end

button.MouseButton1Click:Connect(clicked)

player is a service…?? I think you meant for yourself not the service. You can get the player parameter using PlayerAdded event.

1 Like

My problem is that the player won’t have the character when the player clicked on the TextButton.

1 Like

The error prints

1 Like

There is a way to switch characters. Here’s a fairly simple tutorial:

1 Like

Did you change your script? But the issue is Players service is not a real player, it’s a service, and it does not have a children called Character inside, therefore it’s indexing nothing, instead, if it’s a real player, indexing the character will return the character in Workspace.

1 Like

Wait it’s unclear to me, if your struggling to make the GUI elements and the how to make shop system work or you just can’t change a players avatar…

1 Like

I changed my script to

local character = game.Workspace.Dummy
local button = script.Parent
local player = game.Players.LocalPlayer

function clicked()
	player.Character = character
end

button.MouseButton1Click:Connect(clicked)

I already have the shop gui, and the gui elements, but I don’t know how to change the player’s character to the character that the player bought.

I tried this before, but this isn’t what I want.

Changing the players character is actually kinda a little trickier said than done…
Have a look here, you must actually rig the player properly, just saying so it doesn’t cause future issues with compatibility between different rigs…

1 Like

You can change the player’s character by applying the Rig’s HumanoidDescription

player.Character.Humanoid:ApplyDescription(character.Humanoid.HumanoidDescription)

Has to be in a server script

1 Like

Thats a lot better, suggestion to OP would be to actually make a complete server-side shop, to prevent hacking…
1. Hackers can’t see the code thus can handle currency much easily without having to look for ways to secure it
2. Shop management would be much simpler this way too…

How you may do it is create a button that fires a remote event to the server, server then replicates shop GUI from server storage… into players, PlayerGui… (make sure you do this in a module script… then assign all gui’s by player name to a dictionary… [example: GUIStorage[plr] = gui]
after this you can simply create a Remote Function and that way have a secure system :smiley:

server sided shop that i made

with leaderstats
LEADERS_Shop.rbxm (31,3 KB)
without leaderstats
NOLEADERS_Shop.rbxm (31,1 KB)

1 Like

I mean I wouldn’t recommend this, since that doesn’t do any of the things I said above.
Hackers can easily steal replicated storage items meaning they could simply clone the tools in replicated storage to their Player Backpack :confused:
It’s simple so I guess thats pretty nice about it but, if we are talking about security then I don’t see this being a good system…

Disabling scripts is very easy :eyes:

Can you disable server scripts, if you were an exploiter?
I’m unsure as to if you could, I could be wrong :confused:

You can disable server scripts if it’s available in the explorer when client-sided, but server scripts disabling on client sided does no effect and still runs.

Basically, you can disable the script but you can’t disable the behavior. It only marks it as disabled in client-sided.

1 Like

Sorry for the late reply, @LuaAlbi, @CreepingGamingTV, @Xapelize. Also for @LuaAlbi’s shop roblox file, it doesn’t open because it is in rbxm file instead of rbxl file.