Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how can i change a player's clothes in a shop without changing everyone's clothes? [closed]

Asked by 4 years ago

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

game.Players.PlayerAdded:Connect(function(player)
    local clickDetector = script.Parent
    script.Disabled = false

    local function onMouseClick()
        local oldchat = game.ReplicatedStorage.npcchatyesno:Clone()
        oldchat.Parent = player.PlayerGui
        local oldwalkspeed = player.Character:WaitForChild("Humanoid").WalkSpeed
        local oldjumppower = player.Character:WaitForChild("Humanoid").JumpPower
        player.Character:WaitForChild("Humanoid").WalkSpeed = 0
        player.Character:WaitForChild("Humanoid").JumpPower = 0
        local chatbox = player.PlayerGui.npcchatyesno
        chatbox.Frame.TextBox.Text = "Would you like to buy the Assassin Rags for 10 rupees?"
        chatbox.Frame.ButtonYes.Text = "Yes"
        chatbox.Frame.ButtonNo.Text = "No"
        chatbox.Frame.NPCName.Text = "Joseph"
        local function yesbuttonPressed()
            if player.PlayerRupees.Value >= 10 then
                chatbox.Frame.ButtonYes:Destroy()
                chatbox.Frame.ButtonNo:Destroy()
                player.PlayerRupees.Value = player.PlayerRupees.Value - 10
                player.ClothesValue.Value = "assassinrags"
                player.Character.RogueShirt.ShirtTemplate = "http://www.roblox.com/asset/?id=2083053293"
                player.Character.RoguePants.PantsTemplate = "http://www.roblox.com/asset/?id=2083054667"
                chatbox.Frame.TextBox.Text = "Thank you for the purchase."
                wait(1.5)
                chatbox:Destroy()
                player.Character.Humanoid.WalkSpeed = 22
                player.Character.Humanoid.MaxHealth = 100
                player.Character.Humanoid.Health = 100
                player.Character:WaitForChild("Humanoid").JumpPower = oldjumppower
            else
                chatbox.Frame.ButtonYes:Destroy()
                chatbox.Frame.ButtonNo:Destroy()
                chatbox.Frame.TextBox.Text = "You don't have enough rupees for this."
                wait(1.5)
                chatbox:Destroy()
                player.Character:WaitForChild("Humanoid").WalkSpeed = oldwalkspeed
                player.Character:WaitForChild("Humanoid").JumpPower = oldjumppower
            end
        end
        chatbox.Frame.ButtonYes.MouseButton1Down:connect(yesbuttonPressed)
        local function nobuttonPressed()
            player.Character:WaitForChild("Humanoid").WalkSpeed = oldwalkspeed
            player.Character:WaitForChild("Humanoid").JumpPower = oldjumppower
            chatbox:Destroy()
        end
        chatbox.Frame.ButtonNo.MouseButton1Down:connect(nobuttonPressed)
    end

    clickDetector.MouseClick:connect(onMouseClick)
end)
0
Do you mind if you shortened the code and added frequent comments? Also if you have published the place, can you please link it? Thanks. User#30567 0 — 4y
0
Try using a remoteevent, and have it fired by the client, and not the server. NightmareMcPro87 30 — 4y

Closed as Non-Descriptive by hiimgoodpack, ForeverBrown, EmbeddedHorror, and maumaumaumaumaumua

This question has been closed because its title or content does not adequately describe the problem you are trying to solve.
Please ensure that your question pertains to your actual problem, rather than your attempted solution. That is, you were trying to solve problem X, and you thought solution Y would work, but instead of asking about X when you ran into trouble, you asked about Y.

Why was this question closed?