(I am just now getting into scripting, so it might be messy or unusual)
I have a TextButton in a ScreenGui that is only visible to me. This script is inside of the TextButton. Basically, it creates a sound into my head only (I'm using R15) and plays it when the TextButton is clicked by me, and it isn't working.
sound = Instance.new("Sound") sound.Parent = game.Workspace.SheriffTaco.Head sound.SoundId = "rbxassetid://846221985" sound.MaxDistance = 500 sound.RollOffMode = "Linear" sound.Volume = 10 script.Parent.MouseButton1Click:connect(function() sound:Play() end)
local function PlaySound(ID,Parent) local Sound = Instance.new("Sound") Sound.SoundId = "rbxassetid://"..ID Sound.PlayOnRemove = true Sound.MaxDistance = 500 Sound.RollOffMode = "Linear" Sound.Parent = Parent Sound.Volume = 10 Sound:Destroy() end local c = game:GetService("Players"):GetPlayers() script.Parent.MouseButton1Down:Connect(function() for i = 1,#c do local Player = c[i] if Player.Name == "SheriffTaco" then PlaySound(846221985, Player.Character.Head) end end end)
--I found out how to work this, Make sure you have the gui enabled for you on however you know for you to see it only, then make sure the parent of this script is a textbutton, and when the textbutton is clicked this would function, make sure you don't click it right away because theres the wait(2), try it out, it worked for me.
wait(2) sound = Instance.new("Sound") sound.Parent = game.workspace.SheriffTaco.Head sound.SoundId = "rbxassetid://846221985" sound.MaxDistance = 500 sound.RollOffMode = "Linear" sound.Volume = 10 script.Parent.MouseButton1Click:connect(function() sound:Play() end)