So I have a local script in which I get the part my tool touched. I need to get the same part that I touched in the server script, how do I do it?
Local script:
event:FireServer(hit)
Script:
local event = script.Parent:WaitForChild("WallEffects")
event.OnServerEvent:Connect(function(hit)
print(hit)
end)
But when I try to do this, the function creates it as a player instead of my part
Yup anything done by client → server will have the first argument as the player.
I suggest checking the documentation first before posting since it might save you a ton of time.
Just google “roblox (whatever you need scripting wise)” For example “roblox remote event”
The client will automatically send the player as a first argument when you fire an event from it so you dont need to supply it. But when the event arrives on the server the first argument must always be the player, i.e.:
event.OnServerEvent:Connect(function(player,hit)
print(player.Name .. " hit " .. hit)
end)