Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

broadcasting mouse.Target over a remote event killing player even though it should be "Stone"?

So i am a tool that when you click on a certain block it destroys the block. but when i broadcast mouse.Target it always seems to be the humanoid even if the name of it is "Stone". Client side code:

local Players = game:GetService("Players")
 
local localPlayer = Players.LocalPlayer
local backpack = localPlayer:WaitForChild("Backpack")
 
local tool = Instance.new("Tool")
tool.RequiresHandle = false
tool.CanBeDropped = false 
tool.Parent = backpack
 
tool.Equipped:Connect(function(mouse)
	mouse.Button1Down:Connect(function()
		if mouse.Target and mouse.Target.Parent then
			game.ReplicatedStorage.DestroyBlock:FireServer(mouse.Target)
			print(mouse.Target.Name)
		end
	end)
end)

Server side code:

game.ReplicatedStorage.DestroyBlock.OnServerEvent:Connect(function(part)
	part:Destroy()
end)

Thank you!

1 comment

0

To accept my answer, you gotta click mark as solution or accept answer.

1 answer

✓ Accepted answer

Make sure you add player as one of the parameters.

game.ReplicatedStorage.DestroyBlock.OnServerEvent:Connect(function(plr, part)
    part:Destroy()
end)

4 comments

0

omg thank you so mych

0

how do i mark as answered

0

you gotta click mark as solution or accept answer

0

thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.