local RS = game:GetService("ReplicatedStorage") local DeletePart = RS:WaitForChild("DeletePart") local DeletePartFunction = RS:WaitForChild("DeletePartFuction") local UIS = game:GetService("UserInputService") local Part = game.Workspace.Part
UIS.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.E then print("E") DeletePartFunction:InvokeServer(Part) print("Hi") end end)
--put this code in the local script in the staterplayerscripts
local RS = game:GetService("ReplicatedStorage") local DeletePart = RS:WaitForChild("DeletePart") local DeletePartFunction = RS:WaitForChild("DeletePartFuction")
DeletePartFunction.OnServerInvoke = function(player, Part) Part:Destroy() end
--I put this code in ServerScriptService
-- i already added remote functions and remote events in the rep storage

2 comments
isn't the code in the wrong services? the one where you're checking for the serverInvoke is in the script where the other part should be in. You invoke server at the local script in starterPlayerScripts and the one where you check in serverscriptservice.
Please indent your code.