#Why my script is not working

1 messages · Page 1 of 1 (latest)

compact cypress
#

This is the script:
local ProximityPromt = script.Parent
local Milk = ProximityPromt.Parent

ProximityPromt.Triggered:Connect(function(player)
local Player = game.Players:FindFirstChild(player.Name)
local leaderstats = Player:WaitForChild("leaderstats")
local money = leaderstats:FindFirstChild("Money")
local nuhuh = Milk:FindFirstChild("nuh-uh")
local MoneySound = Milk:FindFirstChild("Money")

if money >= 10 then
    MoneySound:Play()
else
    nuhuh:Play()
end

end)
It's supposed to play a specific sound if you have less than 10 money or if you have more than 10 money

terse atlas
#

Is this a local or server script

#

In this case neither would work as intended anyway

#

Prompt.Triggered only works on the server, and to play a sound only to the player who interacted with it, you’d have to send a remote event to the client

#

Also, for the player you can instantly access the player from triggered

#

U dont have to require them from game. Players

nimble nacelle
#

Local proximityprompt = script.parent

terse atlas
#

Oh Im stupid

#

Frgt abt the pic

#

Any errors in console

nimble nacelle
#

Maybe use Money.Value instead

#

@compact cypress

terse atlas
#

OHH

#

Dat the problem

nimble nacelle
#

Maybe

compact cypress
#

There is somenthing wrong

nimble nacelle
#

?

compact cypress
#

When I try to buy it at the first time and I got the money the sound is the MoneySound but If it not my first try trying to buy the sound is always nuhuh

compact cypress
#

Dont mind

#

I think its all done

nimble nacelle
#

Alright...

compact cypress
#

Sometimes the money sound work and sometimes not

nimble nacelle
#

Oh

compact cypress
chrome surgeBOT
#

studio** You are now Level 2! **studio

nimble nacelle
#

?

compact cypress
nimble nacelle
#

Uhm

compact cypress
#

No

nimble nacelle
#

Okay

#

Hm so from what i saw

#

Nuh huh always plays?

#

Oh wait

compact cypress
nimble nacelle
#

Okay

#

Stop both sounds before
If money >= 10

compact cypress
nimble nacelle
compact cypress
#

Like this?:
local ProximityPromt = script.Parent
local Milk = ProximityPromt.Parent

ProximityPromt.Triggered:Connect(function(player)
local Player = game.Players:FindFirstChild(player.Name)
local leaderstats = Player:WaitForChild("leaderstats")
local money = leaderstats:FindFirstChild("Money")
local nuhuh = Milk:FindFirstChild("nuh-uh")
local MoneySound = Milk:FindFirstChild("Money")

nuhuh:Stop()
MoneySound:Stop()
if money.Value >= 10 then
    MoneySound:Play()
else
    nuhuh:Play()
end

end)

nimble nacelle
#

Yes

compact cypress
#

Im trying it a few times to view if is that

#

I think that worked ty

nimble nacelle
#

Ok

compact cypress
#

I just join for a second to try another script and when I bought the milk the sound was nuhuh

#

Its like sometimes is working and sometimes not

terse atlas
#

Do u have more than 10 money when u do it

#

Or 10 money exactly?

compact cypress
#

Why?

compact cypress
tender pelican