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

GetMouse via LocalScript isn't working?

Asked by
u_g 90
9 years ago

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
0
What is the parent of the script? fishguy100 135 — 9y
0
Also, why are you using values for the player and the mouse? fishguy100 135 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

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

0
Where would the Client Code be? u_g 90 — 9y
0
Thanks very much, it works. u_g 90 — 9y
Ad

Answer this question