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

How do I create an onclick screen GUI?

Asked by 8 years ago

I have been trying to create a Screen GUI that pops up when a brick is clicked.When the button is clicked it resets the character. When I click the brick in test mode nothing happens. What am I doing wrong?(I have no scripting experience)

Here's a copy of my script:

function onClicked(playerWhoClicked) if onClicked then local screenGui = Instance.new("ScreenGui") screenGui.Parent = script.Parent

local textButton = Instance.new("TextButton") textButton.Parent = screenGui textButton.Position = UDim2.new(0, 50, 0, 50) textButton.Size = UDim2.new(0, 140, 0, 60) textButton.TextColor3 = BrickColor.White().Color textButton.Style = 2 textButton.Text = "Reset Character"

textButton.MouseButton1Down:connect(function() game.Players.LocalPlayer.Character.Humanoid.Health = 0 end script.Parent.ClickDetector.MouseClick:connect(onClicked)

0
code block please yoshi8080 445 — 8y
0
has it got a click detector inside it? LittleBigDeveloper 245 — 8y

1 answer

Log in to vote
0
Answered by
MaxxHD 10
8 years ago

If I were you what I would do is create the Gui you want and put it in lighting. Name it Reset then put this in a script inside the brick:

function onClicked(Player)
    game.Lighting.Reset:Clone().Parent = Player.PlayerGui
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

Then inside your Gui insert a local script and put:

function onClicked()
    game.Players.LocalPlayer.Character:BreakJoints()
end 
script.Parent.MouseButton1Down:connect(onClicked)

Btw, make sure you have a ClickDetector inside your brick.

Ad

Answer this question