I want it to make it delete parts that are named guard but instead it deletes other parts! How do i fix this?
function ds(hit) if hit.Name ~= "Guard" then hit:Destroy() end end script.Parent.Touched:Connect(ds)
Either like this..
function ds(hit) if hit.Name ~= "Guard" then --hit:Destroy() else hit:Destroy() end end script.Parent.Touched:Connect(ds)
or like this
function ds(hit) if hit.Name == "Guard" then hit:Destroy() end end script.Parent.Touched:Connect(ds)
Simple fix. Your script makes it so that parts that are not equal, or ~=, to “Guard” will be deleted. To fix this, just remove the tilde.
function ds(hit) if hit.Name = "Guard" then hit:Destroy() end end script.Parent.Touched:Connect(ds)
On line 2, you put "If hit.name ~= Guard then", what's wrong about that is this: "~=". Basically "~=" means not equal, since you put that there it will destroy everything that is not equal to "Guard". So basically it destroys everything that is not named "Guard". You can easily fix it by switching "~=" to "==". Good luck making your game :)
function ds(hit) if hit.Name == "Guard" then hit:Destroy() end end script.Parent.Touched:Connect(ds)
local Brick = script.Parent function OnTouched(Hit) if Hit.Name == "Guard" then Hit:Destroy() end end Brick.Touched:Connect(OnTouched)
Simple.
First of all you said if it is not named guard then destroy everything that is not named guard. It should look more like this.
01 function ds(hit) 02 if hit.Name == "Guard" then 03 04 hit:Destroy() 05 06 07 end 08 09 10 end 11 script.Parent.Touched:Connect(ds)