Buttons dont work

Hello there, I can’t figure out why but the buttons don’t work on my emotes system, I tried to add print sections to help me debug it, but it turns out that the button doesn’t get registered.

Client script:

local plr = game.Players.LocalPlayer
local com = game.ReplicatedStorage.Communicator

local currentlyplaying
local currentlyplayingval = false

repeat wait() until plr.CharacterAdded:Wait()

local char = plr.Character or plr.CharacterAdded:Wait()
wait(1)

script.Parent.BestMates.MouseButton1Click:Connect(function()
	print("clicked")
	if currentlyplaying == "BestMates" and currentlyplayingval == true then
		print("fired to stop emotes")
		com:FireServer("StopEmotes")
		script.Parent.Visible = false
	else
		com:FireServer("PlayEmote","BestMates",{plr = plr, char = char})
		script.Parent.Visible = false
		currentlyplaying = "BestMates"
		currentlyplayingval = true
	end
end)

script.Parent.GetGriddy.Animated.MouseButton1Click:Connect(function()
	if currentlyplaying == "Griddy" and currentlyplayingval == true then
		com:FireServer("StopEmotes")
		script.Parent.Visible = false
	else
		com:FireServer("PlayEmote","Griddy",{plr = plr, char = char})
		script.Parent.Visible = false
		currentlyplaying = "Griddy"
		currentlyplayingval = true
	end
end)
	
script.Parent.InDaParty.Animated.MouseButton1Click:Connect(function()
	if currentlyplaying == "InDaParty" and currentlyplayingval == true then
		com:FireServer("StopEmotes")
		script.Parent.Visible = false
	else
		com:FireServer("PlayEmote","InDaParty",{plr = plr, char = char})
		script.Parent.Visible = false
		currentlyplaying = "InDaParty"
		currentlyplayingval = true
	end
end)

script.Parent.JubiSlide.Animated.MouseButton1Click:Connect(function()
	if currentlyplaying == "JubiSlide" and currentlyplayingval == true then
		com:FireServer("StopEmotes")
		script.Parent.Visible = false
	else
		com:FireServer("PlayEmote","JubiSlide",{plr = plr, char = char})
		script.Parent.Visible = false
		currentlyplaying = "JubiSlide"
		currentlyplayingval = true
	end
end)

Server script:

local animmodule = require(game.ReplicatedStorage.EmoteModule)
local gmusic = game:GetService("SoundService").SoundGroup

function fadein(plr)
	if plr.PlayerGui.Main.Settings.LowVolume.Value == false then
		for i, music in gmusic:GetChildren() do
			music.Volume = 1.5
			wait(0.05)
			music.Volume = 1.4
			wait(0.05)
			music.Volume = 1.3
			wait(0.05)
			music.Volume = 1.2
			wait(0.05)
			music.Volume = 1.1
			wait(0.05)
			music.Volume = 1
			wait(0.05)
			music.Volume = 0.9
			wait(0.05)
			music.Volume = 0.8
			wait(0.05)
			music.Volume = 0.7
			wait(0.05)
			music.Volume = 0.6
			wait(0.05)
			music.Volume = 0.5
		end
	elseif plr.PlayerGui.Main.Settings.LowVolume.Value == true then
		for i, music in gmusic:GetChildren() do
			music.Volume = 0.8
			wait(0.05)
			music.Volume = 0.7
			wait(0.05)
			music.Volume = 0.6
			wait(0.05)
			music.Volume = 0.5
		end
	end
end

function fadeout(plr)
	if plr.PlayerGui.Main.Settings.LowVolume.Value == false then
		for i, music in gmusic:GetChildren() do
			music.Volume = 0.5
			wait(0.05)
			music.Volume = 0.6
			wait(0.05)
			music.Volume = 0.7
			wait(0.05)
			music.Volume = 0.8
			wait(0.05)
			music.Volume = 0.9
			wait(0.05)
			music.Volume = 1
			wait(0.05)
			music.Volume = 1.1
			wait(0.05)
			music.Volume = 1.2
			wait(0.05)
			music.Volume = 1.3
			wait(0.05)
			music.Volume = 1.4
			wait(0.05)
			music.Volume = 1.5
		end
	elseif plr.PlayerGui.Main.Settings.LowVolume.Value == true then
		for i, music in gmusic:GetChildren() do
			music.Volume = 0.5
			wait(0.05)
			music.Volume = 0.6
			wait(0.05)
			music.Volume = 0.7
			wait(0.05)
			music.Volume = 0.8
		end
	end
end

local Emotes = {
	
	["BestMates"] = function(params)
		local plr = params.plr
		local char = params.char
		local track = animmodule.PlayAnim(char,script.BestMates)
		
		local assets = {}
		track.Stopped:Connect(function()
			fadeout(plr)
			for i,v in pairs(assets) do
				v:Destroy()
			end
		end)
		fadein(plr)
		table.insert(assets,animmodule.PlaySound(char,script.BestMates1))
	end,
	
	["Griddy"] = function(params)
		local plr = params.plr
		local char = params.char
		local track = animmodule.PlayAnim(char,script.Griddy)
		
		local assets = {}
		track.Stopped:Connect(function()
			fadeout(plr)
			for i,v in pairs(assets) do
				v:Destroy()
			end
		end)
		fadein(plr)
		table.insert(assets,animmodule.PlaySound(char,script.Griddy1))
		table.insert(assets,animmodule.PlaySound(char,script.Griddy2))
	end,
	
	["InDaParty"] = function(params)
		local plr = params.plr
		local char = params.char
		local track = animmodule.PlayAnim(char,script.InDaParty)
		
		local assets = {}
		track.Stopped:Connect(function()
			fadeout(plr)
			for i,v in pairs(assets) do
				v:Destroy()
			end
		end)
		fadein(plr)
		table.insert(assets,animmodule.PlaySound(char,script.InDaParty1))
		table.insert(assets,animmodule.PlaySound(char,script.InDaParty2))
	end,
	
	["JubiSlide"] = function(params)
		local char = params.char
		local track = animmodule.PlayAnim(char,script.JubiSlide)
		
		local assets = {}
		track.Stopped:Connect(function()
			for i,v in pairs(assets) do
				v:Destroy()
			end
		end)
	end,
}

game.ReplicatedStorage.Communicator.OnServerEvent:Connect(function(plr,mode,replicateName,params)
	
	print("communicator fire detected, plr: "..plr.Name..", mode: "..mode..", emote: "..replicateName.." params: "..params)
	
	if mode == "PlayEmote" then
		if Emotes[replicateName] then
			animmodule.StopAllAnims(plr.Character)
			print("stopped emotes")
			Emotes[replicateName](params)
			print("started playing emote")
		end
	elseif mode == "StopEmotes" then
		animmodule.StopAllAnims(plr.Character)
		print("stopped emotes")
	end
end)

I’d be very happy if anyone could help me out

I’m assuming that “clicked” doesn’t output from line 13, even though you click the button?

Hey, any errors/output that could help us?

Yes, thats correct. It doesn’t print anything.

Nothing, nothing prints or any output occurs.

Can you please quickly confirm that the button has the Interactable property turned on?

1 Like

Okay, can you try printing something after “wait(1)” part?

Yes, It’s turned on.
Ekrano kopija 2024-11-02 151707

can you try adding a print statement after the wait?

Alright I tried it, but it didn’t print anything too…

what I thought, try removing the "

repeat wait() until plr.CharacterAdded:Wait()

local char = plr.Character or plr.CharacterAdded:Wait()
wait(1)

"

lines

Hold on, I reset, and it printed.

Alright, that works. But the module doesn’t recognize the Humanoid anymore.

try adding back the

local char = plr.Character or plr.ChracterAdded:Wait()

line.

No need, I just removed the params thingy cuz I won’t even need it because when the remote is fired, the player is included in there too so i just gave the function the player instead of “params” and it worked. Thanks for the suggestion though.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.