Server Event Firing Multiple Times

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.

Oh yeah it worked with the local sound BTW

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.

Didn’t work, https://gyazo.com/bde50bfd7ebec5abdc2af5b8acee413d It got even worse with the event now firing 5 times

Could you post your code please?

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)
1 Like

I could only think it’s your server script being the issue or the script being cloned.

Just to check, are you using this event to play animations anims already play on the client?

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.

I would try reimplementing this by checking if the item is in the cart, i’m guessing you have the buttons all in the same place then?

I just made a confirm button for each item and it works fine, thanks for your help however

1 Like