For some weird reason, “stuff happens” prints two times whenever I press a block. Any Idea how I could fix it?
local player = game.Players.LocalPlayer
local tool = script.Parent
Set = game.ReplicatedStorage.RemoteEvents.SetEvent
local Target = game.Workspace.Block
Set.OnServerEvent:Connect(function(Player, Target, Tool)
if Target.Name == "Block" and Tool.Parent == Player.Character then
print ("stuff happens") --Instead of printing, add whatever function here you like so the tool can do something when you click the block
end
end)
local Tool = script.Parent --make sure this is a Tool object
Set = game.ReplicatedStorage.RemoteEvents.SetEvent
local Target = game.Workspace.Block
Tool.Equipped:Connect(function(Mouse)
Mouse.Button1Down:Connect(function()
Set:FireServer(Target, Tool)
end)
end)
Tool.Activated:Connect(function()
Set:FireServer(Target, Tool)
end)
That is because you have two functions calling the event. You can either remove the top or bottom function. Although I would remove the top function since the bottom is more simple and does the same job!