|
| 08 Oct 2016 03:24 PM |
| Hello, I need help with something.. Basically I'm making roleplaying game and what I want to ### ## background music of bird chirping. But I have done that. However I want it to only be in the mornings.. Easier said, in a specific time and then stops after. Any suggestions ? Please help. |
|
|
| Report Abuse |
|
|
|
| 08 Oct 2016 03:26 PM |
| "I want to add birds chirping" |
|
|
| Report Abuse |
|
|
|
| 08 Oct 2016 03:34 PM |
| http://wiki.roblox.com/index.php?title=API:Class/Lighting/GetMinutesAfterMidnight |
|
|
| Report Abuse |
|
|
vexieh
|
  |
| Joined: 22 Oct 2009 |
| Total Posts: 3468 |
|
|
| 08 Oct 2016 03:40 PM |
Alternatively, you could create a function to convert TimeOfDay into a number.
local FetchTime = function() return tonumber(string.sub(game.Lighting.TimeOfDay, 0, 2) .. "." .. string.sub(game.Lighting.TimeOfDay, 4, 5)) end
print(FetchTime())
My TimeOfDay is set to '15:38:00', so FetchTime() would return the 15.38
So then you can just do something like
if(FetchTime() > 9.5)then Sound:Play() end
|
|
|
| Report Abuse |
|
|
vexieh
|
  |
| Joined: 22 Oct 2009 |
| Total Posts: 3468 |
|
|
| 08 Oct 2016 03:41 PM |
"return the 15.38" return 15.38* oops
|
|
|
| Report Abuse |
|
|
|
| 08 Oct 2016 04:28 PM |
| in Fetchtime... May I ask what 9.5 is meant to be? |
|
|
| Report Abuse |
|
|
|
| 08 Oct 2016 04:34 PM |
Probably "9:50:00", but might be "9:05:00".
Good scripter, but probably not good enough a builder to be an RBXDev... |
|
|
| Report Abuse |
|
|
vexieh
|
  |
| Joined: 22 Oct 2009 |
| Total Posts: 3468 |
|
|
| 08 Oct 2016 04:48 PM |
9.5 would be 09:50:00, 9.05 would be 09:05:00
|
|
|
| Report Abuse |
|
|
|
| 08 Oct 2016 05:41 PM |
Can't I do it easier? by doing
Start = game.workspace.sound:play() pause = game.workspace.sound:Pause()
while true do
Pause wait () --Value
Start -- The time when it's morning.
|
|
|
| Report Abuse |
|
|
vexieh
|
  |
| Joined: 22 Oct 2009 |
| Total Posts: 3468 |
|
|
| 08 Oct 2016 05:45 PM |
No easier way for doing it other than getting the time
|
|
|
| Report Abuse |
|
|
|
| 08 Oct 2016 05:48 PM |
| Oh darn.. The time thingy gets too confusing for me for some reason. I guess i'll have to figure an easier way. |
|
|
| Report Abuse |
|
|
|
| 09 Oct 2016 05:50 AM |
I've done this til now but still a problem
local FetchTime = function() return tonumber(string.sub(game.Lighting.TimeOfDay, 0, 2) .. "." .. string.sub(game.Lighting.TimeOfDay, 4, 5)) end
local function Fetchtime() end
print("FetchTime")
FetchTime() "return 14.00"
if(FetchTime() > 9.05)then game.Workspace.Sound:Play() end
When I run the script this error occures
"Workspace.Sound.Script:12: attempt to call a number value" |
|
|
| Report Abuse |
|
|