Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

GetMouse via LocalScript isn't working?

I'm currently trying to get the instance mouse of a player, using a LocalScript, and then allowing a Script to use this object value. However, the script I have right now doesn't work. There are no errors, and the InstanceMouse value does not change. Please help.

The following code is inside of a LocalScript. There are two values, InstancePlayer and InstanceMouse.

local mouse = script.InstancePlayer.Value:GetMouse()
script.InstanceMouse.Value = mouse -- This (InstanceMouse) is an ObjectValue
script.Parent.Disabled = true

2 comments

0

What is the parent of the script?

0

Also, why are you using values for the player and the mouse?

1 answer

✓ Accepted answer

Maybe try something like this:

Add a RemoteFunction to ReplicatedStorage and name it "Mouse"

Client Code:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MouseEvent = ReplicatedStorage:WaitForChild("Mouse")

local Player = game:GetService("Players").LocalPlayer

function MouseEvent.OnClientInvoke()
	return Player:GetMouse()
end

Server Code:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MouseEvent = ReplicatedStorage:WaitForChild("Mouse")
local Mouse = MouseEvent:InvokeServer()

From there, you can use the variable "Mouse" just like you would in any other script

2 comments

0

Where would the Client Code be?

0

Thanks very much, it works.

This discussion is preserved as it was. New answers, comments, and votes are closed.