✓ Accepted answer
You should make it local for the player, and you're trying to access UserInputService in a server script so it changes for the entire server. To make it local, you first need to add a RemoteEvent into ReplicatedStorage.
In this case, I'll call it DisableMouse as game.ReplicatedStorage.DisableMouse (It's a Remote Event)
You can put the RemoteEvent inside a folder or anything but you have to change the locator (e.g. workspace.Part3). Here is your modified Server script:
First, we need to find the player who touches it. Then fire the remote event only to that player who touched it, so only that player will have their cursor disabled.
Also when you do anything like :GetService, :FindFirstChild it must have a colon (;) instead of .GetService or .FindFirstChild
h = workspace.DisableCursor
function touch(hit)
if hit ~= nil then
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
game.ReplicatedStorage.DisableMouse:FireClient(plr)
end
end
end
h.Touched:Connect(touch)
Add a Local Script in StarterPlayerScripts
game.ReplicatedStorage.DisableMouse.OnClientEvent:Connect(function()
game:GetService("UserInputService").MouseIconEnabled = false
end)
Thank you
1 comment
Thanks a lot! This is exactly what I was looking for! I'd love to give you an upvote but I can't do that yet.