I have been trying for a couple hours to do this and it just wont work at all
one error occurred that says: Players.TheGrimDeathZombie.PlayerGui.MainMenu.Options.OptionsFrame.Main:2: attempt to concatenate field 'PUserId' (a userdata value)
the script is here:
local PrefMusicStore = game:GetService('DataStoreService'):GetDataStore('PrefferedMusic') local PrefMusic = PrefMusicStore:GetAsync('User_'..script.Parent.PUserId) if PrefMusic == nil then PrefMusicStore:SetAsync('User_'..script.Parent.PUserId, "Creative6") script.Parent.Parent.Parent.Creative6:Play() else script.Parent.Parent.Parent:FindFirstChild(PrefMusic):Play() end script.Parent.M1.MouseButton1Click:connect(function() local Items = script.Parent.Parent.Parent:GetChildren() for index, value in ipairs(Items) do if value:IsA('Sound') then value:Stop() end end wait(.1) script.Parent.Parent.Parent.Creative6:Play() PrefMusicStore:SetAsync('User_'..script.Parent.PUserId, "Creative6") end) script.Parent.M1.MouseButton1Click:connect(function() local Items = script.Parent.Parent.Parent:GetChildren() for index, value in ipairs(Items) do if value:IsA('Sound') then value:Stop() end end wait(.1) script.Parent.Parent.Parent.Damage:Play() PrefMusicStore:SetAsync('User_'..script.Parent.PUserId, "Damage") end)
Provided that your P_UserId is a Value type, then you will need to use script.Parent.PUserId.Value
. This is because script.Parent.PUserId is just a container for PUserId.Value, so if you want to concatenate a string with it, you will need to use the .Value.