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

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

Asked by 3 years ago

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!

0
To accept my answer, you gotta click mark as solution or accept answer. raid6n 2196 — 3y

1 answer

Log in to vote
0
Answered by
raid6n 2196 Moderation Voter Community Moderator
3 years ago

Make sure you add player as one of the parameters.

game.ReplicatedStorage.DestroyBlock.OnServerEvent:Connect(function(plr, part)
    part:Destroy()
end)
0
omg thank you so mych dosechickens 2 — 3y
0
how do i mark as answered dosechickens 2 — 3y
0
you gotta click mark as solution or accept answer raid6n 2196 — 3y
0
thanks dosechickens 2 — 3y
Ad

Answer this question