Why does this frame script not work?

the frame variable is supposed to be
local frame = game.StarterGui.ScreenGui.Frame

Also, I forgot to mention, use a global handler

1 Like

and how do i make a global handler in this script? i didn’t learn that part

That still does not work because the startergui is only for when a player joins the game it can’t be changed when a player is already inside the game

Global handlers are regular scripts that are just grey

can you give me an example or type it into the script??

local clickdetector = script.Parent
local sound = script.Parent.Parent.Sound
local soundid = sound.SoundId
local clickdetector2 = script.Parent.Parent.Parent.Part.ClickDetector

clickdetector.MouseClick:Connect(function(player)
	sound.Playing = true
	print("1")
	player.PlayerGui.ScreenGui.Frame.Visible = true
end)

clickdetector2.MouseClick:Connect(function(player)
	sound.Playing = true
	player.PlayerGui.ScreenGui.Frame.Visible = true
end)

nope still doesn’t work
robloxapp-20201027-2000306.wmv (997.6 KB)

do u have multiple screen guis

also, the click detector should be in the part u r trying to click.

Desktop 2020-10-27 8-03-09 PM-383

If your localscript (inside the model) is a descendant of workspace, it won’t run. Use a Server Script for anything running in workspace

screw it, it won’t work because roblox keeps changing stuff and i can’t figure it out like all i want it for the gui’s visible to be true so i can see it when i click the part. But of course it won’t let me do it cause it likes to do that.

your model is a local script, have you considered making it a ‘Script’ instead?

this will most likely work;

local clickdetector = script.Parent.ClickDetector
local clickdetector2 = script.Parent.Part.ClickDetector

clickdetector.MouseClick:Connect(function(player)
	player.PlayerGui.ScreenGui.Frame.Visible = true
end)

clickdetector2.MouseClick:Connect(function(player)
	player.PlayerGui.ScreenGui.Frame.Visible = true
end)

i already did that but nothing works cause it wants to be annoying like all i should be able to do is this:

local frame = game.StarterGui.ScreenGui.Frame

local clickdetector = script.Parent

clickdetector.MouseClick:Connect(function()
frame.Visible = true
end)

Hm…, I don’t know if this will work because I haven’t test it BUT I hope it works. By the way, this script is in a normal script.

-- Variables
local clickdetector = script.Parent
local sound = script.Parent.Parent.Sound
local soundID = sound.SoundId
local clickdetector2 = script.Parent.Parent.Parent.Part.ClickDetector

-- Script
clickdetector.MouseClick:Connect(function(player) -- When the first click detector has been clicked
-- Variables
local Frame = player:WaitForChild("PlayerGui").ScreenGui.Frame
-- Script
sound:Play() -- Play the sound
Frame.Visible = true -- Make the frame visible
end)

clickdetector2.MouseClick:Connect(function(player) -- When the second click detector has been clicked
-- Variables
local Frame = player:WaitForChild("PlayerGui").ScreenGui.Frame
--script
sound:Play() -- Play the sound
Frame.Visible = true -- Make the frame visible
end)

I put some notes in the script so your not confuse. Hope this help :slightly_smiling_face:.

2 Likes

ohh so thats what i needed to do. Btw it actually works now thanks

No problem. And by the way, you can make my reply a solution to help other people.