You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I know the title isnt worded too well, Im going to try and word this the best I can.
I have a tool that has two parts, a local script and a serverscript. When the player clicks(Activates) the tool the local script fires an event which reports the players mouse position to the server, then the script under the same tool, recieves the event with the Mouse postion and uses that to throw the tool in the direction that was clicked. Pretty simple.
- What is the issue? Include screenshots / videos if possible!
BUT! Ive somehow done it in a such a way so that if two players, are holding the same tool, and 1 of them clicks, the OTHER player’s tool which has the same script, is triggered by the event and THEIR tool then gets thrown to the first players mouse.
You can see the issue. Im not every good with Remote events and Ive looked on the forum and I found a guy with a similar problem but it never got solved, or he never posted that it did.
Is there a way I can setup the event so that when the local script activates the event, it then only gets received by the same player’s tool? Or is there just a whole easier way Im not seeing?
This is the Local Script:
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Tool = script.Parent
local Player = Players.LocalPlayer
print(Player)
local Mouse = Player:GetMouse()
local ThrowEvent = ReplicatedStorage:WaitForChild("ThrowBrickEvent")
Tool.Activated:Connect(function()
-- Fire the server event with the mouse's target position
ThrowEvent:FireServer(Mouse.Hit.Position)
end)
And this is the beginning of the function in the serverscript (also found under the same tool)
ThrowEvent.OnServerEvent:Connect(function(player, mouseHitPosition)
-- the actual function works so I wont include it to save space, but this is how I fire it.
end)