I am trying to make a script when a player touched a certain "part" it will clone then destroy but when I end the script it says I need to correct it.
SCRIPT:
if game.Players.Player1.Humanoid.onTouched then game.Workspace.Part:Clone end then wait(10) game.Workspace.Part:Remove() end
Touched
is an event, and it needs to be treated as such. Here's a quick rundown of how events work:
function onTouched(hit) -- Events need a function (which will be run every time the event is fired) local cloned = game.Workspace.Part:clone() -- clone() is a method. cloned.Parent = game.Workspace -- Forgot this the first time. You need to give your new part a parent wait(10) -- Wait 10 seconds game.Workspace.Part:Destroy() -- Destroy is better than remove end game.Players.Player1.Torso.Touched:connect(onTouched) -- Connecting our function to the event. Note that this is for the player's torso, there is no Touched event for Humanoids.
Different events pass different arguments. A great way to figure out which arguments are passed is on the ROBLOX Wiki. The page for the touched event is right here.
game.Players.Player1.Character.Torso.Touched:connect(function(hit) local cloned = workspace.Part:clone() cloned.Parent = workspace game:GetService("Debris"):AddItem(cloned,10) end)