I'm trying to make a UFO in my ROBLOX place, and wanted to create a system that would play an audio when the UFO passes overhead. I created a part, inserted an audio into the part, then placed a script in the audio. So it looks like:
Part->Audio->Script
I plan the system to register when a Humanoid is touched, and if the part is going faster than say, 300 Studs per second, I want it to play an audio (preferably the audio would be played only for the person(s) that was touched by the part) so I wrote a script that goes as follows:
while true do
if script.parent.parent.Velocity.Magnitude>299 then
script.Parent:play()
wait(5)
script.Parent:stop()
else
wait()
end
wait()
end
As you can see I'm missing the part about the humanoid being touched, but I'm not sure how to write that. I'm really new to scripting, and I don't know the proper context for these commands. Help would be greatly appreciated.
Thanks!
You can use Lua's logical operators: 'and', 'or', and 'not' are the most commonly used. In your case, it sounds like you want to do something like:
You can also "nest" if statements: