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

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

Asked by 3 years ago
Edited 3 years ago

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)

0
Are you running this script in a localscript? loowa_yawn 383 — 3y
0
No it is not local HauntedUSA_NEW 5 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

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.

0
This will work just fine WINDOWS10XPRO 438 — 3y
Ad

Answer this question