Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is my Chat Command not working?

When the player say ":D", an image should appear above the player's head. The image is made up from a BillboardGui, which I put inside the script.

function onChatted(msg, speaker)
    
	source = string.lower(speaker.Name)
	msg = string.lower(msg)

	if (msg == ":D") then 
		local laugh = script.Laugh:Clone() -- The BillboardGui is called "Laugh"
		laugh.Parent = speaker.Character.Head
		wait(2)
		laugh:remove() -- image should remove after 2 seconds
	end
end

function onPlayerEntered(newPlayer) 
	newPlayer.Chatted:connect(function(msg) onChatted(msg, newPlayer) end) 
end
 
game.Players.ChildAdded:connect(onPlayerEntered)

When I say ":D" in game nothing happens, but when I dragged the BillboardGui inside the player's head in studio mode, the image appears like it should. Help please?

Thanks.

2 answers

✓ Accepted answer

Have you set the Adornee of the billboard gui?

It looks like your script is fine, but I don't see you setting it's Adornee. Here;

local laugh = script.Laugh
laugh:clone().Parent = speaker.Character.Head
laugh.Adornee = speaker.Character.Head
wait(2)
speaker.Head.Laugh:destroy()

~TDP

1 comment

0

Didn't know Adornee was needed ;P

Try this:

game.Players.PlayerAdded:connect(function(plr)
plr.Chatted:connect(function(msg)
    if msg == ":D" then 
        local laugh = script.Laugh
        laugh:clone().Parent = speaker.Character.Head
        wait(2)
        speaker.Head.Laugh:destroy()
    end
end)
end)


This discussion is preserved as it was. New answers, comments, and votes are closed.