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

I am kind of confused why this wont work [variable not working?]

i have tried to make a music player gui but it seems the variable is messed up and is nto detectign the id from textbox? i am quite new to lua a year of doing it heres my code

local id = script.Parent.Parent.ID.Text local left = game.Workspace.left local right = game.Workspace.right script.Parent.MouseButton1Click:Connect(function() right.Sound:Stop() left.Sound:Stop() right.Sound.SoundId = ('rbxassetid://' .. id) left.Sound.SoundId = ('rbxassetid://' .. id) end)

2 comments

0

Are you running this script in a localscript?

0

No it is not local

1 answer

Why did you use ('rbxassetid://' .. id), that should not be in brackets.

local id = script.Parent.Parent.ID.Text 
local left = game.Workspace.left
local right = game.Workspace.right 

script.Parent.MouseButton1Click:Connect(function() 
	right.Sound:Stop() 
	left.Sound:Stop() 

	right.Sound.SoundId = "rbxassetid://" .. id	
	left.Sound.SoundId = "rbxassetid://'".. id 
end)

And also this needs to be in a local script for the MouseButton1Click to work properly, you cant register clicks in a server scripts.

1 comment

0

This will work just fine

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