Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Really basic/simple MouseButton1Click script doesn't work?

Hey there, so this REALLY simple script doesn't work for some reason. No errors.

script.Parent.MouseButton1Click:Connect(function()
	game.StarterGui.Menu.Frame.Black.ImageTransparency = 1
end)

yep, it's that basic but it doesn't work. how do i fix it??

7 comments

0

is this in a gui?

0

yes

0

make shure black is an image and make shure you spelt everything right

1

StarterGui is a replication container, its assets are individually cloned and transferred to each Player. The behavior of this container is much like StarterGear, notice how you would be referencing 'Backpack' instead? You need to index the 'PlayerGui' container of the local Player Object.

0

Think, if the user-interface was actually under one container, every Player's screen would be identical; even if you weren't interacting with UI itself, if someone where to open a menu, it would replicate.

0

I'd hope that your TextButton is at least within the same file-path as your Menu, so to bring general ease, place the LocalScript in a convenient location where you can simply access everything through relative hierarchical indexing.

0

You should try changing MouseButton1Click to MouseButton1Down.

1 answer

✓ Accepted answer

I think your problem is happening because your calling these from StarterGui. When a player joins the game, any objects inside of StarterGui, will be duplicated and placed into a folder inside the player called PlayerGui.

So, how to fix this?

Im assuming your using a local script, so try this:

script.Parent.MouseButton1Click:Connect(function()
    local player = game.Players.LocalPlayer
    player.PlayerGui.Menu.Frame.Black.ImageTransparency = 1
end)

This script fetches the player using LocalPlayer, then it gets Black from the Frame inside the Menu Gui, which is inside the PlayerGui. Then it changes the image Transparency to one.

Hope this helps!

NOTE: LocalPlayer can only be activated on a local script, in case your wondering.

This discussion is preserved as it was. New answers, comments, and votes are closed.