I really don't understand why you do this function lightOnFire() print("Lighting on fire!") end with functions instead of just
print("Lighting on fire!")
I really don't understand why you do this function lightOnFire() print("Lighting on fire!") end with functions instead of just
print("Lighting on fire!")
Hello,
This is a bit advanced , but it is a good explanation.
function hookmake ()
local hook = Instance.new("Part")
hook.Name = "Projectile"
hook.Anchored = false
hook.CanCollide = false
hook.Transparency = 0
hook.BrickColor = BrickColor.new("Dark stone grey")
hook.Material = "Metal"
hook.Size = Vector3.new(0.75,0.4,0.4)
local hookmesh = Instance.new("SpecialMesh")
hookmesh.MeshId = "rbxassetid://1321670738"
local hookatach = Instance.new("Attachment")
hookatach.Name = "RopeAttachment"
hookatach.Visible = false
hook.Parent = game.Lighting
hookmesh.Parent = hook
hookatach.Parent = hook
hookatach.Position = Vector3.new(0,0,0.3)
return hook,hookmesh,hookatach
end -- This is a function I made.
My question is would you write all that everytime you need the specific instance or just call the function?
The answer is obviously you will call the function everytime you need it.
hookmake()
In your case, it is a simple script.
function lightOnFire()
print("Lighting on fire!")
end
The answer is obvious you would not want to write print("Lighting on fire!") everytime you need the desired ouput.
Just by calling the function it will output. lightOnFire()
Function is a way to make life easier. In life everything has a function and it is the same in programming.
Thank you for reading.
Feel free to ask any questions.
PS : Your other solution.
t = 0 -- time
while true do wait(.1)
t = t + 1 -- 1 hour in the game is 1 minute in the real life.
game.Lighting:SetMinutesAfterMidnight(t) -- Keeps the time cycle going on.
if game.Lighting:GetMinutesAfterMidnight() == 18 * 60 then -- This is 1080 minutes.
print(game.Lighting:GetMinutesAfterMidnight())
end
if game.Lighting:GetMinutesAfterMidnight() == 6 * 60 then -- This is 360 minutes.
print(game.Lighting:GetMinutesAfterMidnight())
end
end
Thx
I made a street light script but it doesn't work here if game.Lighting:GetMinutesAfterMidnight()== 660 then script.Parent.Material=Enum.Material.Plastic script.Parent.PointLight.Enabled=false end if game.Lighting:GetMinutesAfterMidnight()== 1860 then script.Parent.Material=Enum.Material.Neon script.Parent.PointLight.Enabled=true end
Replace the prints.
Ok so I made a new script which is T=0 while true do T=T+10 game.Lighting:SetMinutesAfterMidnight(T) wait(.1) if game.Lighting:GetMinutesAfterMidnight()== 660 then script.Parent.Material=Enum.Material.Plastic script.Parent.PointLight.Enabled=false end if game.Lighting:GetMinutesAfterMidnight()== 1860 then script.Parent.Material=Enum.Material.Plastic script.Parent.P
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
a function is when you input something and expect an output, for example local function (input) if input == true then print("im true!") elseif input == false then print("im false!")