Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 10 years ago

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.

0
Please use the code block button on your code, this meaning we see the code in correct format. RaverKiller 668 — 10y
0
I did. Can you help me? broboch479 15 — 10y

1 answer

Log in to vote
0
Answered by
modFrost 130
10 years ago

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

Answer this question