Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Really basic/simple MouseButton1Click script doesn't work?

Asked by 3 years 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 55 — 3y
0
yes OreyTheOre 52 — 3y
0
make shure black is an image and make shure you spelt everything right surviarlTheJefkillre 55 — 3y
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 6913 — 3y
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 6913 — 3y
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 6913 — 3y
0
You should try changing MouseButton1Click to MouseButton1Down. NuggetHasJoined 7 — 3y

1 answer

Log in to vote
0
Answered by
Oxprem 140
3 years 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