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

Script that picks a random sound from a folder and plays it, not working?

Asked by
O3hros -3
3 years ago

I do not what to do in this situation, help would be great..

`local random = game.Workspace.WinSounds
local selectrandom = math.random(1,3)
script.Parent.Touched:Connect(function(hit)
    local h = hit.Parent:FindFirstChild("Humanoid")
    if (h~=nil) then
        local selected = random:GetChildren()
        local final = selected(selectrandom)
        final:Play()
        game.ReplicatedStorage.vals.Winner.Value = hit.Parent.Name
        script.Parent:Destroy()
    end
end)`

1 answer

Log in to vote
0
Answered by 3 years ago

Try doing selected[selectrandom] with square brackets.

0
Thx! O3hros -3 — 3y
Ad

Answer this question