Im trying to script that destroys parts when you click it but i cant connect mouse.Target to a remove event this is the script that i have
This is the local script
local UserInputService = game:GetService("UserInputService") local ReplicatedStorage = game:GetService("ReplicatedStorage") local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
UserInputService.InputBegan:Connect(function(input, mouse) if input.UserInputType == Enum.UserInputType.MouseButton1 then mouse.Target:FireServer(mouse) end end)
This is the server script
local ReplicatedStorage = game:GetService("ReplicatedStorage") local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
mouse.Target.OnServerEvent:Connect(function(player, mouse) mouse.Target:Destroy() end)
You are trying to fire a mouse target, which is OBVIOUSLY not a remote event. It can result in errors and next time check the most obvious things first. In local script change the entire script to
local UserInputService = game:GetService("UserInputService") local ReplicatedStorage = game:GetService("ReplicatedStorage") local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent") UserInputService.InputBegan:Connect(function(input, gameProcessed) if input.UserInputType == Enum.InputType.MouseButton1 then RemoteEvent:FireServer(game.Players.LocalPlayer:GetMouse().Target) end end)
and change the server script to
local ReplicatedStorage = game:GetService("ReplicatedStorage") local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent") RemoteEvent.OnServerEvent:Connect(function(player, mouseTarget) mouseTarget:Destroy() end)