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

How shall I fix this?

Asked by
Yeevivor4 155
9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.
player = script.Parent.Parent
 mouse = player:GetMouse()
 PartsLeft = game.Workspace.PartsLeft
function colorChange()
    if mouse.Target ~= nil then
    PartsLeft.Value = PartsLeft.Value + 1
    end
end

mouse.Button1Down:connect(colorChange)

I put this script in StarterGUI so that the player will be identified more easily. The thing is that when I play in "Solo Mode" it works just fine but when I go into "Start Server with 2 people" the output error says that Attempt to index global "mouse". What is wrong with this script? How come the players in the server can not do the same thing as in "Solo Mode". I also tried to put the script into Workspace, and identify player as game.Players:getChildren() but it did not work.

1 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

The PlayerMouse is only accessible from a LocalScript, not a regular script (so the Workspace solution couldn't work anyway)

Ad

Answer this question