Ad
Log in to vote
0

how to make a frame visible w/ click detector? (instarterplayerscipts)

Asked by 2 months ago
Edited 2 months ago
its a localscript also its in starterplayerscripts


local GUI = UI local Button = GUI.Button
local player = game.Workspace.localPlayer
    local repStorage = game:GetService("ReplicatedStorage")
    local remote = repStorage:FindFirstChild("ButtonClick")
    mouse = player:GetMouse()
    local idoit = game.Workspace.CHING.ClickDetector
    UI = game.StarterGui.KiKidied.Frame --idk why i named it that no judge

    idoit.MouseButton1Click:Connect(function()

    UI.Visible = true

end)

0
misspelled 'idiot' lol unsatisfie_d 1207 — 2mo
0
uhhhhh natonator63 3 — 2mo

1 answer

Log in to vote
0
Answered by
xPolarium 846 Moderation Voter
2 months ago
Edited 2 months ago

You're not using the correct event for the ClickDetector. The correct event is 'MouseClick'. You're also not defining the GUI that the player sees. Every GUI you have in StarterGui will be cloned and given to a player's PlayerGui each time they spawn. StarterGui is just a folder the server sees and the client wont be able touch it.

--Prefedine services you'll use at the top
local Players = game:GetService("Players")
local RepStorage = game:GetService("ReplicatedStorage")

--You get local player from the Players service
local player = Players.LocalPlayer

--Localize those variables
local mouse = player:GetMouse()

--Don't understand this but ok
local remote = RepStorage:FindFirstChild("ButtonClick")

--Since we're in a local script, you should wait for things to load
local idoit = workspace:WaitForChild("CHING"):WaitForChild("ClickDetector")

local PlayerGui = player:WaitForChild("PlayerGui") -- idk why this needs to wait

--assuming you have a GUI named Kikidied and a Frame inside of it
local UI = playerGui:WaitForChild("KiKidied"):WaitForChild("Frame")

idoit.MouseClick:Connect(function()
    UI.Visible = true
end)

Some things to note is to make better names for variables and how you define objects/instances. You can also use the Object Browser located in the 'View' tab in Studio to get quick info on the functions, events or properties of a certain object.

Ad

Answer this question