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

How would I get the player from mouse?

Asked by 4 years ago

I need to get the player in order to make my script work however, I don´t know how to "get" the player from their mouse. Here´s my script.

Tool = script.Parent
Handle = Tool:WaitForChild("Handle")

Tool.Equipped:Connect(function(player)
    player.Hidden.Tool.Value = 1
end)

Tool.Unequipped:Connect(function(player)
    player.Hidden.Tool.Value = 0
end)

0
Is this a script or localscript? Jahaziel_VanDerHas 238 — 4y
0
Script AndriusTheGreat 140 — 4y
0
The output keeps telling me that hidden isn´t a child of mouse AndriusTheGreat 140 — 4y

2 answers

Log in to vote
1
Answered by
Syclya 224 Moderation Voter
4 years ago

Tool.Parent would be your character, then use GetPlayerFromCharacter to get the player itself.

Ad
Log in to vote
1
Answered by 4 years ago

Alright, so, let's see

A tool should typically have a localscript, because those are the ones you should be using to interact with the client, so first things first move the code to a localscript.

After you have that, you can just use

local Player=game:GetService"Players".LocalPlayer

to figure out which player the script is running for, and then use remote events and functions where necessary in order to interact with the server.

I hope these wiki articles can help you get used to communicating between local and server scripts.

https://developer.roblox.com/en-us/articles/Converting-From-Experimental-Mode

https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events

Answer this question