So I’m a newbie practicing making a script from scratch and I’m getting an error which I really can’t see what’s wrong. I’ve been watching TheDevKing and learned quiet a lot again in just 2 days. Putting my knowledge to use and looking at the script, it all looks fine to me yet it’s giving an error.
-- Trying to make it rain killbricks with a script using instances btw.
while true do
wait()
local lolpart = Instance.new("Part", game.Workspace)
lolpart.Anchored = false
lolpart.Position = Vector3.new(0,50,0)
lolpart.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid.Health = 0
end
end)
end
But I did put an end? Wouldn’t that close the “do” from the while loop as it wants? I’m a bit confused and would appreciate someone to explain what’s wrong in my simple script?
let me explain how the end’s in your code work real quick
information
while true do wait()
lolpart.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
end
end)
end
the first line calls a while loop
all loops end in “end” except for repeat loops
repeat loops end in “until”
while true do
end
for Count = 1, 5, 1, do
end
repeat
until false
now we get to the event connection
lolpart.Touched:Connect(function(hit)
end)
all functions end with “end” as well, but how did we get the “)” after the “end”?
basically “(function” that first part started a beginning parenthesis, and you must end every parenthesis, which is why “end)” is used
if hit.Parent:FindFirstChild("Humanoid") then
end
and if statements also end in “end”
so remember all beginning parenthesis need an end parenthesis(unless you have a string)