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

Why does my script only work in play solo but not on the live server?

Asked by 7 years ago

My script only works in play solo, when I play on the server it doesn't work this is the script

script.Parent.MouseButton1Click:connect(function()
  local RS = game:GetService("ReplicatedStorage")
  local item = RS:WaitForChild("LinkedSword")
  local price = 50
  local Player = game.Players.LocalPlayer
  local stats = Player:WaitForChild("leaderstats")
  if stats.Coins.Value>= price then
    stats.Coins.Value=stats.Coins.Value - price
    local cloned=item:Clone()
  local cloned2=item:Clone()
  cloned2.Parent=Player.Backpack
  cloned.Parent=Player.StarterGear
  end
 end)

Here's a link to a screen shot of the errors.

Hope you can help.

1 answer

Log in to vote
0
Answered by
Nogalo 148
7 years ago

You're defining Player as LocalPlayer which only works in LocalScript. You can either put this script inside a LocalScript then set up a remote event that would fire the event on the server side or you can redefine the player as the one who clicked the button

0
I'm quite new to scripting so can you give me an example of redefining the player as the one who clicked the button? bobsville2000 -7 — 7y
0
aye thats what i wanted to say greatneil80 2647 — 7y
Ad

Answer this question