part = Instance.new("Part") part.Parent = game.Workspace Instance.new("Part") part.Anchored = false part.BrickColor = BrickColor.new("Dark green") part.Position = Vector3.new(0,100,0) part.Size = Vector3.new(0.5,3,0.5) local part = script.Parent local function onPartTouch(otherPart) local partParent = otherPart.Parent local humanoid = partParent:FindFirstChildWhichIsA("Humanoid") if humanoid then humanoid.Health = 0 end end part.Touched:Connect(onPartTouch)
If I paste everythin from local part = script.Parent and so on into a normal part it will work but won't work with Instance.new? Is it possible to fix that?
If you want the script's parent to be the new part, then try this:
local part = Instance.new("Part", workspace) part.Anchored = false part.BrickColor = BrickColor.new("Dark green") part.Position = Vector3.new(0, 100, 0) part.Size = Vector3.new(0.5, 3, 0.5) script.Parent = part local function onPartTouch(otherPart) local humanoid = otherPart.Parent:FindFirstChild("Humanoid") if humanoid then humanoid.Health = 0 end end) part.Touched:Connect(onPartTouch)