I have a tool that contains a proximity prompt, a animation, an script (obviously) and an sound.
I want to make it so if another player triggers the proximity prompt, the player who is holding the tool plays the animation and the sound.
Some things to mention:
The proximity prompt shouldn’t be visible for the player holding the tool
My game has a currency system so, I want it to take away 10 money from the player who triggered the proximity and give it to the player who is holding the tool
The animation to end upon the sound ending
I have found nothing online about this so this is my last option
Here’s what I’ve tried to use to make it work:
local tool = script.Parent.Parent.Parent
local prox = script.Parent
local sgong = prox.Parent.sgong
tool.Equipped:Connect(function(player)
prox.Enabled = true
prox.Triggered:Connect(function(plr)
if plr.leaderstats.Money.Value < 10 then
return
else
plr.leaderstats.Money.Value -= 10
player.Character.leaderstats.Money.Value += 10
local hum = player.Character.Humanoid
local anim = hum:LoadAnimation(script.Parent.Animation)
anim:Play()
sgong:Play()
wait(sgong.TimeLength)
anim:Stop()
sgong:Stop()
end
end)
end)
If anybody knows how to make this work, I’d be very grateful.
Just tried and it worked on studio (you should test to see if it works in game). Here is what i did:
i have 2 scripts, a local script and a server script
It works beautifully, sorry for the late response, I was busy all day. Thank you for the solution for that problem but it doesn’t really solve my main issue. I managed to fix half of it on my own, yet, thank you very much.