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

I'm making an onClicked ScreenGui. Are there any mistakes?

Asked by 6 years ago

My script was made in 5 minutes, it's really short and it's kind of rushed. I don't know if there are any mistakes. I need help fixing this, thank you.

local Part = script.Parent

Part.Clicked:connect(function(onClicked)
    local C = script.Parent.MouseButton1Click:connect(function()
    if C then
        Player.PlayerGui.ScreenGui.Frame.Visible = true
    end
end

1 answer

Log in to vote
0
Answered by 6 years ago

Assuming you have a ClickDetector in the part that the variable "Part" equals, .Clicked is not an event of part neither is it an event of a ClickDetector. But I'm going to assume you don't have a click detector at all so here is what you did wrong:

  1. Clicked is not a valid event of a part
  2. MouseButton1Click is not a valid event of part either (assuming this script is in a part based on variable names
  3. The function you connected to the non-existent event is not written correctly at all
  4. Player is not a variable nor is it anything you can refer to without creating a variable (line 6)

enough of listing your faults, here is the fixed version of what you posted assuming there is not a click detector inside of the variable Part and Part is actually a basepart (idk if this is even what you intended to do as the script you wrote has no information)

local Part = script.Parent
local Player = 'Player Name Here' --Case Sensitive
local clickDetector = Instance.new('ClickDetector')
clickDetector.Parent = Part

clickDetector.MouseClick:connect(function()
    game.Players[Player].ScreenGui.Frame.Visible = true
end)

hopefully this script is something near what you intended to do.

0
It was nearly what I was looking for, but it helped. Thanks! Crazykookie2 5 — 6y
Ad

Answer this question