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

How do I create an onclick screen GUI?

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)

2 comments

0

code block please

0

has it got a click detector inside it?

1 answer

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.

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