I want this script to detect when a noob from the Noob Printer 1 touches this brick, and when it does, I want it to destroy.
I am not very good at scripting, and this is a tycoon, so the noobs are supposed to be destroyed when they hit the end. The noobs just end up stacking on the brick and don’t destroy.
As I said, I am not very good at scripting, so I haven’t done much. I have tried to look on the dev hub but haven’t found anything.
This is what I have so far:
function bye()
script.Parent.Touched:connect(function(hit)
local noob = game.Workspace["Noob Printer 1"][" "]
if hit.Name == noob then noob:Destroy()
--script to open the door
end
end)
end
while true do
wait(0.2)
bye()
end
(The [" "] is the name of the noob I’d like to destroy
Any help would be appreciated.
function bye()
script.Parent.Touched:Connect(function(hit)
local noob = game.Workspace["Noob Printer 1"][" "]
if hit.Name == noob.Name then noob:Destroy()
end
end)
end
script.Parent.Touched:Connect(function(itemHit)
local Character
if itemHit.Parent:FindFirstChild("HumanoidRootPart") then
Character = itemHit.Parent
elseif itemHit.Name == "HumanoidRootPart" then
Character = itemHit
end --You can remove line 3 to 7 if you don't want it to check for a humanoid.. then remove the "Character and" from the if statement below.
if Character and Character.Name == "Noob" then script.Parent:Destroy() end
end)
You’d have to put parameters to determine what a “noob” is for you. I used the Character’s Model Name being Noob as the parameter.
You also don’t need a while loop for this as the script will activate, whenever it’s touched by any object.
Thank you very much! This worked when I didn’t search for the HumanoidRootPart, and just the name of the noob, though i still get the output error, Workspace.killbrick.Script:2: attempt to index nil with ‘Name’
Hey quick question,
do you know how to have this script run without the error,
Workspace.Base1.Friend Dropper.killbrick.Script:2: attempt to index nil with ‘Name’ - Server - Script:2
23:08:50.108 Stack Begin - Studio
23:08:50.108 Script ‘Workspace.Base1.Friend Dropper.killbrick.Script’, Line 2 - Studio - Script:2
23:08:50.108 Stack End - Studio
I apoligize for the late response, this is my code:
script.Parent.Touched:Connect(function(hit)
if hit.Parent.Name == " " then
hit.Parent:Destroy()
end
end)
“ “ is the name of the noobs that i need it to destroy
And here is the error message again:
Workspace.Base1.Friend Dropper.killbrick.Script:2: attempt to index nil with ‘Name’ - Server - Script:2
23:08:50.108 Stack Begin - Studio
23:08:50.108 Script ‘Workspace.Base1.Friend Dropper.killbrick.Script’, Line 2 - Studio - Script:2
23:08:50.108 Stack End - Studio