Why does this frame script not work?

here is the script:

local clickdetector = script.Parent

local sound = script.Parent.Parent.Sound

local soundid = sound.SoundId

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

local frame = game.StarterGui.ScreenGui.Frame

clickdetector.MouseClick:Connect(function()

sound.Playing = true

frame.Visible = true

end)

clickdetector2.MouseClick:Connect(function()

sound.Playing = true

frame.Visible = true

end)

so whats supposed to happen is when i click the “skull” (part) a frame’s visibility is supposed to be true but instead the frame doesn’t pop up.

skull:


frame:

You are setting the frame to visible, but in the wrong path. Instead of setting it visible inside of StarterGui (all GUI elements inside of a ScreenGui placed inside of StarterGui are rendered when the player spawns inside of PlayerGui), set it visible in the player’s PlayerGui.

You can get the player from the argument passed on the MouseClick event.

ClickDetector.MouseClick:Connect(function( player )
	-- do stuff
end)

here is my script now but it still don’t work:

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

local player = game.Players:FindFirstChild('humanoid')

local frame = game.StarterGui.ScreenGui.Frame

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

clickdetector2.MouseClick:Connect(function(player)
	sound.Playing = true
	frame.Visible = true
end)

Hey Yo2buber99! I guess I have the SOLUTION for your problem!

  • Instead of typing ‘humanoid’ type “Humanoid”
  • Make sure you Made first letter of the (“Humanoid”) part Upper case
  • Make Sure you type MouseButton1Click Instead of MouseClick (If It’s a GUI)
  • Use " " Instead of ’ ’

I hope this helps you! If It Didn’t Work please contact me again! :smiley:

it still dont work here is the script:

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

local player = game.Players:FindFirstChild("Humanoid")

local frame = game.StarterGui.ScreenGui.Frame

clickdetector.MouseButton1Click:Connect(function(player)
	sound.Playing = true
	print("1")
	frame.Visible = true
end)

clickdetector2.MouseButton1Click:Connect(function(player)
	sound.Playing = true
	frame.Visible = true
end)

Sound:Play() sound.Playing is not a valid member.

thats because you don’t have the sound in the right place

im no looking after the sound im tryna make the gui pop up

Hmmm, Are the parts in a Model? Or you typed the variables in only Script? (Example: We have part 1 and part 2, You made the variables in a Script Inside of part 1)

Also, If it’s a Part/Brick you should use “MouseClick” And for GUIs “MouseButton1Click”

Here’s other Solutions!

  • Make sure you type “IsPlaying” Instead Of “Playing”
  • To Play The Song Use “:Play()”
  • Is it a Local Script Or a Script? (Normal)

If you do Sound:Play() it plays the sound. It is not working because when there is an error in the start of the script it will not play the stuff below it.

i have two parts just in case they miss click and yes the script is only a script not a local script, is that the problem do i need to use the local script instead?

the sounds work perfectly fine everytime i click the button (“skull”) the sound plays and thats not the problem

Game.StarterGui won’t change the playergui

im confused of what you are talking about can you explain more of it??

do player.PlayerGui.ScreenGui.Frame

do this instead of your frame.

There’s a lot of problems with your script so I’ll list off as much as I can see.

  1. First off you need to use WaitForChild(“ObjectName”) when locating things on the client. It may also be used on server scripts in some scenarios, but mainly the client.

  2. You’re using MouseButton1Click on a ClickDetector. It’s supposed to be MouseClick bro…

  3. If sound.Playing is not a member inside of sound, then it’s most likely a property you’re trying to access or a sound you’re trying to play. sound:Play(), or sound.IsPlaying = true is the solution to that.

local player = game.Players:FindFirstChild("Humanoid")

This will not do… You’re either trolling, or your username must be Humanoid. Why are you even locating player? player isn’t even used in the script…

Use a global handler:

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)

Sorry, it didn’t copy and paste.

I changed it.

here is the script: (still don’t make much sense plz don’t be mad)
can you remake this so i don’t have to waste so much time trying to figure the smallest and supposedly was easy?

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

local player = game.Players:FindFirstChild("Humanoid")

local frame = game

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)

here is a picture of what it looks like: Desktop 2020-10-27 7-47-26 PM-764

delete the player variable at the start. it is messing the whole thing up. Also, delete the frame variable too.

1 Like