Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

This script works in Studio but not in game? I'm using a Music Script made by someone on roblox

I'm using a music script model that I found in the tool box it works just fine in studio but in the server it doesn't work. Here's the script

--Made by Stickmasterluke
gw=game.Workspace


function message(text,time)
	local oldmsg=gw:FindFirstChild("Hint")
	if oldmsg then
		oldmsg.Parent=nil
	end
	local spacenumber=time*25
	local msg=Instance.new("Hint")
	msg.Parent=gw
	--[[for i=1, spacenumber do
		wait(1/25)
		local maketext=""
		for i2=1, i do
			maketext=maketext.." "
		end
		maketext=maketext..text
		for i2=1, spacenumber-i do
			maketext=maketext.." "
		end
		msg.Text=maketext
	end]]
	msg.Text=text
	wait(0)
	msg.Parent=nil
end

last=""
lastlast=""
while true do
	wait(1)
	local tracks=script:GetChildren()
	local rn=math.random(1,#tracks)
	local track=tracks[rn]
	if track~=nil then
		if track.className=="Sound" and track.Name~=last and track.Name~=lastlast then
			lastlast=last
			last=track.Name
			message(track.Name,5)
			track:play()
			wait(80)
			track:pause()
		end
	end
end

1 answer

✓ Accepted answer

Next time, please use the blue Lua circle button to create a code block to put your code inside, so we can read it.

Here are some places for improvement on this script

className should be ClassName

The Hint Object is deprecated, and you shouldn't be using it. Use RobloxGui's instead.

2 comments

0

What should I change the ("Hint") into?

0

Whatever you want. Try a TextLabel

This discussion is preserved as it was. New answers, comments, and votes are closed.