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

How would I make a Gui that appears when another player is clicked on?

I need a Gui for my Pokemon game that opens up and offers the option of sending a battle request to the other player.

What I have so far:

local player = script.Parent.Parent
m = player:GetMouse()
m.Button1Down:connect(function()
    if m.Target then 
        if m.Target.Parent then
            local user = Game.Players:GetPlayerFromCharacter(m.Target.Parent)
            if user and user ~= player then -- Checks to see if the player is clicking on another player
	            local c = user.Character
				if (player.Character.Torso.Position - c.Torso.Position).magnitude < 20 then
					local bg = Instance.new("BillboardGui",c.Head)
					bg.Adornee = c.Head
					bg.Size=UDim2.new(1,0,1,0)
					bg.StudsOffset = Vector3.new(3,0,0)
					bg.Name = "Interact"
					game.Lighting.Interacting:Clone().Parent = bg
					bg.Interacting.Text = user.Name
				end	
        	end
        end
	end
end)

Does not work. Please help.

2 comments

0

Please use the code block button on your code, this meaning we see the code in correct format.

0

I did. Can you help me?

1 answer

Put in every player's torso, it should be a local script.

local Torso = script.Parent
local Click = Instance.new("ClickDetector",Torso)
Click.Name = "Hue"
Click.MaxActivationDistance = 15 -- Studs away to be able to click.
Click.MouseClick:connect(function(PlayerWhoClicked)
--Take it from here please.
end)

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