I have a localscript which fires a remoteevent when certain blocks are touched but I need to be able to know the specific block I touched on the server. Is this possible?
the localscript
local character = script.Parent local humanoid = character:WaitForChild("Humanoid") local rs = game:GetService("ReplicatedStorage") local remote = rs:WaitForChild("touchedEvent") local debounce = false local touched = humanoid.Touched:Connect(function(hit, limb) if debounce then return end -- if part not in object folder, return if hit.Parent ~= workspace.Objects then return end remote:FireServer() -- fires the server script when the object is touched debounce = true wait(0.2) debounce = false end)
the server script (idk how to find the block I touched)
local rs = game:GetService("ReplicatedStorage") local remote = rs:WaitForChild("touchedEvent") remote.OnServerEvent:Connect(function(player) local character = player.Character local humanoid = character:WaitForChild("Humanoid") local headScale = humanoid:WaitForChild("HeadScale") local dScale = humanoid:WaitForChild("BodyDepthScale") local wScale = humanoid:WaitForChild("BodyWidthScale") local hScale = humanoid:WaitForChild("BodyHeightScale") end)
Just pass the part as an argument to your remote's :FireServer()
method.
In local script, line 17:
remote:FireServer(hit) -- sends the touched part
In server script, line 4:
remote.OnServerEvent:Connect(function(player, part) -- the part touched gets stored in 'part'
From here you can reference the touched part from inside the server script by addressing the 'part' variable.