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

Script not working on the game but is fine when tested on Studio, can someone help please?

Asked by
Qawstar 32
5 years ago

Haii!

I'm currently trying to make an music player script, which I got done but now when I tried to test it online (on a ROBLOX place), it didin't work. But on ROBLOX Studio, it works perfectly fine.

Here's the script:

while wait(1) do

game.Players.PlayerAdded:Connect(function(player)

end)

local NowPlaying = script.Parent.Parent.TextLabel
local Sound = script.Parent.Parent.SongPlayer

print("The music player has loaded!")

wait(1)

Sound.SoundId = 'rbxassetid://1051512943'
NowPlaying.Text = 'Running in the OOFs'
script.Parent.Parent.SongPlayer:Play()
script.Parent.Parent.SongPlayer.Ended:Wait()
end

:)

0
Remove game.Players.PlayerAdded:Connect(function(player) end) from the loop in while wait(1) do. FrostyEmpire_1 0 — 5y
0
Don't use wait(1) as a condition. User#19524 175 — 5y
0
What I'm about to say might seem dumb, but it's also a fact. Some things only work in Roblox Studio, but do nothing in a regular game. User#24366 0 — 5y

1 answer

Log in to vote
-1
Answered by 5 years ago
Edited 5 years ago

replace your whole script with

while wait(1)do
    game.Players.PlayerAdded:Connect(function(player)
        local NowPlaying = script.Parent.Parent.TextLabel
        local Sound = script.Parent.Parent.SongPlayer
        print("The music player has loaded!")
        wait(1)
        Sound.SoundId = 'rbxassetid://1051512943'
        NowPlaying.Text = 'Running in the OOFs'
        script.Parent.Parent.SongPlayer:Play()
        script.Parent.Parent.SongPlayer.Ended:Wait()
    end)
end

tell me if it doesn't work and I'l try re-sripting from scratch

0
why use while wait(1) do? the8bitdude11 358 — 5y
0
Using while wait() do is a bad practice. Aimarekin 345 — 5y
0
With that script, it doesn' work at all. Qawstar 32 — 5y
Ad

Answer this question