how can i change a player's clothes in a shop without changing everyone's clothes? [closed]
this script is supposed to charge a player 10 money to change their clothing however it charges every player in the server 10 money and changes their clothing too but if i use a localscript it would only make the new clothing visible to the player who bought it and wouldn't charge them any money
01 | game.Players.PlayerAdded:Connect( function (player) |
02 | local clickDetector = script.Parent |
03 | script.Disabled = false |
05 | local function onMouseClick() |
06 | local oldchat = game.ReplicatedStorage.npcchatyesno:Clone() |
07 | oldchat.Parent = player.PlayerGui |
08 | local oldwalkspeed = player.Character:WaitForChild( "Humanoid" ).WalkSpeed |
09 | local oldjumppower = player.Character:WaitForChild( "Humanoid" ).JumpPower |
10 | player.Character:WaitForChild( "Humanoid" ).WalkSpeed = 0 |
11 | player.Character:WaitForChild( "Humanoid" ).JumpPower = 0 |
12 | local chatbox = player.PlayerGui.npcchatyesno |
13 | chatbox.Frame.TextBox.Text = "Would you like to buy the Assassin Rags for 10 rupees?" |
14 | chatbox.Frame.ButtonYes.Text = "Yes" |
15 | chatbox.Frame.ButtonNo.Text = "No" |
16 | chatbox.Frame.NPCName.Text = "Joseph" |
17 | local function yesbuttonPressed() |
18 | if player.PlayerRupees.Value > = 10 then |
19 | chatbox.Frame.ButtonYes:Destroy() |
20 | chatbox.Frame.ButtonNo:Destroy() |
21 | player.PlayerRupees.Value = player.PlayerRupees.Value - 10 |
22 | player.ClothesValue.Value = "assassinrags" |
25 | chatbox.Frame.TextBox.Text = "Thank you for the purchase." |
28 | player.Character.Humanoid.WalkSpeed = 22 |
29 | player.Character.Humanoid.MaxHealth = 100 |
30 | player.Character.Humanoid.Health = 100 |
31 | player.Character:WaitForChild( "Humanoid" ).JumpPower = oldjumppower |
33 | chatbox.Frame.ButtonYes:Destroy() |
34 | chatbox.Frame.ButtonNo:Destroy() |
35 | chatbox.Frame.TextBox.Text = "You don't have enough rupees for this." |
38 | player.Character:WaitForChild( "Humanoid" ).WalkSpeed = oldwalkspeed |
39 | player.Character:WaitForChild( "Humanoid" ).JumpPower = oldjumppower |
42 | chatbox.Frame.ButtonYes.MouseButton 1 Down:connect(yesbuttonPressed) |
43 | local function nobuttonPressed() |
44 | player.Character:WaitForChild( "Humanoid" ).WalkSpeed = oldwalkspeed |
45 | player.Character:WaitForChild( "Humanoid" ).JumpPower = oldjumppower |
48 | chatbox.Frame.ButtonNo.MouseButton 1 Down:connect(nobuttonPressed) |
51 | clickDetector.MouseClick:connect(onMouseClick) |