Hi there, so currently I have this script where if a player touches a button, it would clone a RANDOM map from ServerStorage into a folder in the Workspace. Based off of this, how could I play audio so only the player who touched the button would hear on certain maps? (For example, if the player touches the button and "test" map was picked, the "test" audio would play for only the player.)

This is my current script (No mention of any selection of music, just the first part):


local Teleport = "Part3"
local part = script.Parent
part.BrickColor = BrickColor.new("Bright green")

function Touch(hit)
    if hit and hit.Parent and hit.Parent:IsA("Model") then
        print("OK")
    else
        return
    end
    if part.BrickColor ~= BrickColor.new("Bright green") then
        return
    end

    part.BrickColor = BrickColor.new("Bright red")
    local mapstorage = game.Workspace:WaitForChild('nukeeasy')
    mapstorage:ClearAllChildren()

    local mapsinserverstorage = game:GetService('ServerStorage').NukeMaps.Easy:GetChildren()
    local chosenmap = mapsinserverstorage[math.random(1, #mapsinserverstorage)]


    chosenmap = chosenmap:Clone()

    chosenmap.Parent = mapstorage

    print()
    print(hit)
    print(hit.Parent)
    print(hit.Parent:IsA("Model"))
    print(chosenmap)
    print(chosenmap:findFirstChild(Teleport))

this = true
if this == true then
       wait(2) if hit and hit.Parent and hit.Parent:IsA("Model") and chosenmap and chosenmap:findFirstChild(Teleport) then
        
this = false
hit.Parent:moveTo(chosenmap:findFirstChild(Teleport).Position)
   wait(5)
    this = true
end
    

    end
   part.BrickColor = BrickColor.new("Bright green")
end

part.Touched:connect(Touch)

Please note that this script is in a part in a model in a model in the Workspace.

2 comments

0

connect is deprecated, use Connect.

0

ok