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

Mouse and Button1Down Not Working In Server Setting?

Asked by
Pyracel 55
5 years ago

For some reason my simple localscript is not working. Is there anything that points out at you?

local Player = game.Players.LocalPlayer
local Character = Player.Character

repeat wait() until Character ~= nil

local Mouse = Player:GetMouse()



Mouse.Button1Down:connect(function()
    print("Clicked.")
end)

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Where do you have the script? LocalScripts must be in StarterTools or StarterGui to run, when I put it there it worked fine for me.

Just 1 suggestion I have though;

change:

local Character = Player.Character

repeat wait() until Character ~= nil

to just: local Character = Player.Character or Player.CharacterAdded:Wait()

It does the same thing, and in my opinion looks much cleaner

0
Great, and yes it's in StarterGui. Pyracel 55 — 5y
Ad

Answer this question