Trying to make a gui for a cafe.
Im Trying to make a gui button that when i click it changes the Transparancy of the tool im holding.
heres the code tell me what im doing wrong local MainGui = script.Parent
local TextButton = MainGui.TextButton
TextButton.Parent.MouseButton1Click:connect(function(h)
if h.Parent.Name == "Pizza" then
h.Parent.Name = "Pizza"
h.Parent.pesto.Transparency = 0
end
end)
Ive tried Parent/functions and none seem to be working.
This “C” is suppose to be a capital.
it doesnt matter but yes Connect is much better because connect is deprecated but it still works
what does this (h) define? its not meant for the pizza but you who clicked so your trying to set yourself transparent but not the pizza
ive been learning from other scripts and thats what it had
iiLok_i
(ItzLokiHere)
October 19, 2020, 9:45am
#7
Something like this might work:
local tool = (toolobject)
script.Parent.MouseButton1Click:Connect(function()
tool.Transparency = 1
end)
Is there a way to make just one part in the tool to change Transparency?
iiLok_i
(ItzLokiHere)
October 19, 2020, 9:46am
#9
Yes, get the child of the tool:
tool.SomeChild.Transperency = 1
no no no this (h) means anything that clicked the button and the one who clicked means yourself so your the script is trying to set yourself transparent but not the pizza or am i getting this wrong?
iiLok_i
(ItzLokiHere)
October 19, 2020, 9:50am
#11
No, you are right, the h is defining the user who is running the function.
nothing is working im not sure what im doing wrong im using a local script Parented with a textButton
iiLok_i
(ItzLokiHere)
October 19, 2020, 9:51am
#13
Can you send me the tool’s children from explorer?
as Loki said try make a variable of your tool path and then set its properties from the click
1 Like
iiLok_i
(ItzLokiHere)
October 19, 2020, 9:53am
#16
Okay, so here is the script you want to write.
local tool = game.StarterPack.Pizza
local pesto = tool.pesto
script.Parent.MouseButton1Click:Connect(function()
pesto.Transperency = 1
end)
1 Like
its not turning the Transperency to 1 for the pesto when i click the textbutton here is what i got setup
iiLok_i
(ItzLokiHere)
October 19, 2020, 9:56am
#18
Okay, I think I know whats wrong.
First of all, can you send me errors your getting, then try putting the LocalScript inside of the Textbutton
i put it in the textbutton and this is what i got
iiLok_i
(ItzLokiHere)
October 19, 2020, 9:58am
#20
I think I mispelled Transparent.
iiLok_i
(ItzLokiHere)
October 19, 2020, 9:59am
#21
Yes, I am terribly sorry, I mispelled Transparency, replace it and it should work.