I need help making this cash bill

i need help playing a sound localy when this is clicked

the script is very simple

and this is what it looks like btw.
Capture.PNG

oh yeah and im a very new beginner to scripting

1 Like

Create a remote event, :FireClient(player), and then in a local script, connect .OnClientEvent and then just play the sound.

1 Like

im sorry, but im new to scripting and i don’t really know any of that

where should i put the remote event???

Ok, so basically you would have a remote event (let’s just say it is in replicated storage for now). After it has been clicked, you fire the client that clicked it:

game.ReplicatedStorage.RemoteEvent:FireClient(player)

Then on the client (let’s just say you have this in StarterGui), you listen to the event being fired and then play a sound:

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
   script.Sound:Play()
end)

This is a really basic example, but hope it helps. Here is also an article on remote events to help you more in the future: Custom Events and Callbacks | Documentation - Roblox Creator Hub

3 Likes

do you think it would work if i used it in my script?

Yes. If you set it all up right then it should work just fine :slight_smile:

An easier solution than firing a remote event would be parenting a local script each time the player clicks.

Here is how you’d set that up:
image
The Sound you want to play would be in the Dollar Bill block.
The LocalScript would be the child of the Click script.
The ObjectValue would be the child of the LocalScript (we use this to point back to the dollarbill later)

In your click script, you’d wanna add

local sfxScript = script.LocalScript:Clone() -- this makes a new copy of the LocalScript, and puts it in the player
sfxScript.BillValue.Value = script.Parent -- this lets the script know which bill it is
sfxScript.Parent = player.Backpack -- this puts the script in the player, so they get the local effects
sfxScript.Disabled = false -- this enables the script, so the sound plays
wait(x) -- x is how long the audio plays for
sfxScript:Destroy() -- this cleans it up

Here is what goes in the local script:

local bill = script.BillValue.Value
local sfx = bill.Sound

sfx:Play()

To make sure it only plays once, make sure Looped is turned off.

1 Like