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