Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

Could somebody fix my script?

Asked by 9 years ago

It's really unorganized and ineffecient. Plus, it doesnt work.

songs = {179712592,235855135,181547615,143959455,215733323}

a179712592 = "All About That Bass"
a235855135 = "See You Again"
a181547615 = "Centuries"
a143959455 = "Turn Down For What"
a215733323 = "Watch Me"

Model = script.Parent
Music = Model.Music

while wait() do
    Music.SoundId = (math.random(#songs[5]))
    wait(Music.TimeLength)
if Music.SoundId == 179712592 then
function processCommand(speaker, message)
    if message == string.lower("All About That Bass") then
        print(speaker.Name.."has won this round!")
    end
end
    end
end

What I want it to do: - Play a random song from the "songs" table - Detect if a player chats the name of the song (uppercase, lowercase, or any combination)

0
Did you define the chatted event? ChemicalHex 979 — 9y
0
I dont think so. SchonATL 15 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

Your script seems to be fine but however you made some few silly mistakes.

songs = {179712592,235855135,181547615,143959455,215733323}

a179712592 = "All About That Bass"
a235855135 = "See You Again"
a181547615 = "Centuries"
a143959455 = "Turn Down For What"
a215733323 = "Watch Me"

Model = script.Parent
Music = Model.Music

while wait() do
    Music.SoundId = "http://roblox.com/asset/?id="..songs[(math.random(1,#songs)]-- You need the add the SoundFile link in order for the sound to actually play
    wait(Music.TimeLength)
if Music.SoundId == "http://roblox.com/asset/?id=179712592" then--Here.
function processCommand(speaker, message)
    if message == string.lower("All About That Bass") then
        print(speaker.Name.."has won this round!")
    end
end
    end
end

Edit: How do I make the Script print("has won this round!") when the player say "All About That Bass" you ask?

It very easy! I'll comment you through it!

game.Players.PlayerAdded:connect(function(Player)--First we need to get the Player.
    Player.Chatted:connect(function(Message)--Then we need to use the parameter that is named "Player" for the Chatted event. 
if Message == "All About That Bass" then--This the player says "All About That Bass" then" and if he does then...
print(Player.Name.." has won this round!")--It print this.
        end
    end)
end)

If I helped you solve your problem/question the please accept my answer!

0
This works for the most part. However, whenever I chat "All About That Bass", it does not print that I have won the game in the output. SchonATL 15 — 9y
Ad

Answer this question