Ad
Log in to vote
0

Really basic/simple MouseButton1Click script doesn't work?

Asked by 1 month ago

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??

0
is this in a gui? surviarlTheJefkillre 38 — 1mo
0
yes OreyTheOre 30 — 1mo
0
make shure black is an image and make shure you spelt everything right surviarlTheJefkillre 38 — 1mo
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. Ziffixture 6785 — 1mo
View all comments (3 more)
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. Ziffixture 6785 — 1mo
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. Ziffixture 6785 — 1mo
0
You should try changing MouseButton1Click to MouseButton1Down. NuggetHasJoined 7 — 1mo

1 answer

Log in to vote
0
Answered by
Oxprem 105
1 month ago

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.

Ad

Answer this question