For example, if I made a local script saying:
local plr = game.Players.LocalPlayer; local m = plr:GetMouse(); m.Button1Down:connect(function() print(plr.Name.."'s mouse clicked"); end)
it would work perfectly in-studio test mode, but when you go to play the actual game on your ROBLOX client (In-game) it doesn't work at all! Now your next instinct may be to use UserInputService, but if I altered the local script to:
local plr = game.Players.LocalPlayer; game:GetService("UserInputService").InputBegan:connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 then print("plr.Name.."'s mouse clicked"); end end)
But this still behaves the same way! It STILL will only work in-studio mode, and it literally won't work at all in-game. Did ROBLOX deprecate these methods? should I be using a remote function instead? I am kind of lost with this, I need to get this mouse click input to work in-game. Any help would be much appreciated, thanks.
Well, srsly m8 im a harambe at scripting but this is vry new to players
sometisem the local game runs faster then a server so in a local session the game runs on par with the server sense it's hosted locally k :)
so to compensate for the delay from local to server which is your problem here is that your local scripts is to sanic fast then the server you gotta add a delay man
local plr = game.Players.LocalPlayer; repeat wait() until plr; game:GetService("UserInputService").InputBegan:connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 then print("plr.Name.."'s mouse clicked"); end end)
Local Scripts can not run in Workspace
or ServerScriptService
. You should be using ReplicatedFirst
, StarterPack
, StarterGui
, StarterPlayerScripts
, or some other service that gets replicated to the player and allows Local Scripts to run.
That's all I see that could possibly be wrong.
Good Luck!