How do I fix this error

so in a server script I have

local Part = script.Parent
local Event = game.ReplicatedStorage:WaitForChild("CloneEvent")
local Event2 = game.ReplicatedStorage:WaitForChild("DestroyEvent")

Event.OnServerEvent:Connect(function(Player) 
	Part.Touched:Connect(function(Part)
		local humanoid = Part.Parent:FindFirstChild("Humanoid") 
		if (humanoid ~= nil) then
			local PlayerGui = Player:WaitForChild("PlayerGui")
			local Ping = PlayerGui.PingGui.MainFrame.Ping
			local Clone = Ping:Clone()
			Clone.Parent = Ping	.Parent
			Event2:FireClient()
		end
	end)
end)

In a local script I have

local Part = script.Parent
local Event2 = game.ReplicatedStorage:WaitForChild("DestroyEvent")

Event2.OnClientEvent:Connect(function(Player) 
	Part.Touched:Connect(function(Part)
		local humanoid = Part.Parent:FindFirstChild("Humanoid") 
		if (humanoid ~= nil) then
			local Script = script.Parent.Script
			Script:Destroy()
		end
	end)
end)

Everything works beside tin the local script where it destroys the server script
There is an error that says that on where it fires the client in the server script it says “argument 1 missing or nil”

Why Destroy the script when you can disable it?

Where did you put the local script and script?

Player argument is missing. In the FireEvent

Aka you made your function have an argument called player but it is missing or nil. Since you havent sent it to the client script with the FireEvent

1 Like

The server script also has an error

Clone.Parent = Ping	.Parent

Correct

Clone.Parent = Ping.Parent

since there will be multiple parts like this with the script and I want to reduce thew amount of lag.

local script is inside the part along with the server.

Local script has to be in StarterPlayerScripts or StarterCharacterScripts

I still won’t work even though I fixed that.

alright im going to try that.

Blank space

actually is it fine if I keep it inside the part since it will make it easier in the future?

This is because, In a FireClient event, you must specify the player to be fired at.

in the Event2:FireClient() line you’re not giving any parameters.

No the LocalScript has to be in one of those folders or it wont work.

Already said that.

Also, If I were you, I would use a BindableEvent for communcating between server scripts.

a Local script can also run if it’s a descendant of a Player’s backpack.

See here:
https://developer.roblox.com/en-us/api-reference/class/LocalScript

1 Like

Yeah but he has it inside of a workspace instance

I just did it and it still does not work.

what have you tried already? can you give me some details

Did you try this?