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

Can you help me with Sound Properties?

Hello, I am trying to figure out something that deals with Sound. I currently have this following script to play sound for only one person, not all of the other people.

game.Players[script.Parent.Owner.Value].PlayerGui.Sound2:Play()

I used this in my Tycoon kit but it caused different errors, so I was wondering was there any possible way to make the sound be louder the closer you get? Instead of playing at the same Volume through-out the entire game? If you know how please help! Thanks.

Error in Output - Workspace.Berezaa's Tycoon Kit.Tycoons.Bright blue.Purchase:79: bad argument #2 to '?' (string expected, got user data) Script 'Workspace.Berezaa's Tycoon Kit.Tycoons.Bright blue.Purchase', Line 79 Stack end

That's what came up when I touched the button with the script above, it just made the Model that you buy appear but no sound nor did the button disappear...

2 answers

✓ Accepted answer

Your Problem

script.Parent.Owner.Value is an ObjectValue! It already returns the player object. You don't need to search in game.Players for it.


Code

script.Parent.Owner.Value.PlayerGui:WaitForChild('Sound2'):Play()

4 comments

0

I dont think this is a problem in your scripting, but it says Sound2 is not a valid member of PlayerGui?

0

That just means that it's not there. I edited the script to use WaitForChild

0

idek why but its the same error everytime..

0

That means that the sound just isn't there.

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