I'm trying to make a sound play when a user clicks on the screen, that's it.
I already know how to play a sound (when it's in the part itself):
script.Parent.[soundnamehere]:Play()
But I need the sound to play when the user clicks anywhere on the screen.
(Also, I'm trying to make it add to a leaderboard stat, it's optional to add an answer for this but I'd appreciate it!)
You'd need to place this in a localscript in a client-side container (Such as StarterGui):
local Mouse = game.Players.LocalPlayer:GetMouse() Mouse.Button1Down:connect(function() script.Parent.Sound:Play() end)
This is assuming you want it to click anywhere on the screen (no specific objects) and you want the sound to play immediately as you click down.
(Put this in LocalScript)
player = game.Players.LocalPlayer mouse = player:GetMouse() local sound = --Put your sound here! mouse.Button1Down:connect(function() sound:Play() end)