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.
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
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)