I need to just fire this server event once, https://gyazo.com/01d67bb33d41a22726412c1afc8c2437
As you can see there’s a print “emote 4x” which emote prints when the server event is fired, and also my character has 4x of everything inside of him, and the server event its self has a load character function/event. I’ve looked on this forum and asked on scripting helpers and got no answers, I looked it up on youtube and google as well. While there are a few topics about my issue the solutions either don’t work or don’t apply to my situation.
script.Parent.MouseButton1Click:Connect(function()
local SoundService = game:GetService("SoundService")
local sound = game.Workspace.Sounds.Click
SoundService:PlayLocalSound(sound)
local Character = Player.Character
local humanoid = Character:WaitForChild("Humanoid")
local anim = Instance.new("Animation", humanoid)
anim.AnimationId = "http://www.roblox.com/asset/?id=5027685199"
local animTrack = humanoid:LoadAnimation(anim)
animTrack:Play()
anim:Destroy()
Player.PlayerGui.Shop.ShopFrame.Confirm.Visible = true
wait(1)
Player.PlayerGui.Shop.ShopFrame.Confirm.MouseButton1Click:Connect(function()
if not Debounce then
Debounce = true
game.ReplicatedStorage.EventsAndValues.Emote:FireServer(script.Parent.Name)
wait(1)
Debounce = false
end
end)
end)
Before adding the confirm button and the animation track everything worked fine.
You have the functions inside of each other, if you press the first button multiple times, then when you press the second button, the function will run as many times as you clicked the first button.
What you wanna do is move the second button press function outside of the first function.
Also if this is on the client sound:Play() is a much simpler solution.
local Player = game.Players.LocalPlayer
local Debounce = false
script.Parent.MouseButton1Click:Connect(function()
local SoundService = game:GetService(“SoundService”)
local sound = game.Workspace.Sounds.Click
SoundService:PlayLocalSound(sound)
local Character = Player.Character
local humanoid = Character:WaitForChild("Humanoid")
local anim = Instance.new("Animation", humanoid)
anim.AnimationId = "http://www.roblox.com/asset/?id=5027685199"
local animTrack = humanoid:LoadAnimation(anim)
animTrack:Play()
anim:Destroy()
Player.PlayerGui.Shop.ShopFrame.Confirm.Visible = true
wait(1)
end)
Player.PlayerGui.Shop.ShopFrame.Confirm.MouseButton1Click:Connect(function()
if not Debounce then
Debounce = true
game.ReplicatedStorage.EventsAndValues.Emote:FireServer(script.Parent.Name)
wait(1)
Debounce = false
end
end)
If you mean was it already played for the player, yes the animation id is used in the upper part of the script to give a preview, once confirm is pressed then the event fires the purchase, currently I have the confirm button working for all the buyable items, instead I could try to have each one have a button of their own.