Hello,
I am trying to make a script that will project more details onto a new UI frame when specific UIs are clicked for a tower defense game, such as the cost of towers and an enlarged form of a viewport.
The problem is that it doesn’t detect the clicks at all, I tried inserting a print into the loop as well, and I found that it just was not registering the clicks. There were no errors in the code either and the Output had nothing. Here is the code, as well as an image of the object browser in case that yields anything:
local detailname = script.Parent.Parent.Parent.Parent.Details.TowerName
local detailcost = script.Parent.Parent.Parent.Parent.Details.TowerCost
local detailessence = script.Parent.Parent.Parent.Parent.Details.TowerEssence
local detailvp = script.Parent.Parent.Parent.Parent.Details.ViewportFrame
local detailpurchase = script.Parent.Parent.Parent.Parent.Details.Purchase
local towerbtn = script.Parent.Button
local towertext = script.Parent.Button
local towervp = script.Parent
local towercam = script.Parent.Parent.Camera
local tower = script.Parent.Tower
local toweroverlay = script.Parent.OverlayButton
local function refresh ()
print("button pressed")
detailname.Text = towertext.Text
detailcost.Text = "0"
detailessence.Text = "30 Essence"
detailvp.CurrentCamera = towercam
local towerclone = tower:Clone()
towerclone.Parent = detailvp
detailpurchase.Text = "Owned"
end
towerbtn.MouseButton1Click:Connect(refresh)
toweroverlay.MouseButton1Click:Connect(refresh)
Sorry for insane amount of local variables and “.parents” as well.
I don’t think the issue is ZIndex, as for testing I tried pushing all of the relative buttons (TowerOverlay and Towerbtn) to a big ZIndex and pushing all unrelated UI objects to a low ZIndex as well.
hmm maybe try sending a picture of properties? I think Active might just be the only thing to look at though. If thats off it just doesnt send events to it.
I turned active on for all objects and frames, still nothing. Also, doesn’t .Active mean that you can click into 3D objects beneath UI objects?
If you still want the properties, of which object do you want it for?
Oh no you dont need active for everything, but Active just enables events for GUI objects ( at least thats what the textbutton in my game is telling me xD )
I dont think i need the properties, but is that all thats in the Local Script?
Maybe try moving the local script out of the viewport frame ( err so you dont mess up all of your code just make a new script inside the button and print on click )
I made a local script under the buttons and made it print stuff, and it worked! Now all I have to do is copy the code over and change it up a little. I’ll let you know if it works.
When I inserted the script into it, it didn’t work ):
No errors in the output either.
It’s the same code, I just changed the path of the local variables to match.
Uhh I dont know what the issue is. I just tested some examples I was able to get each button to work even the ones inside viewport frames + scripts work there too
You dont have any Yields or anything right? I can only assume the script is disabled or waiting for something to happen for no errors to occur, but also with nothing working.
aha! I found the error! I just had to scroll way up in the output, my bad entirely! It says
“11:39:39.190 Camera is not a valid member of Folder “Players.ValtryekRBLX.PlayerGui.ScreenGui.ShopFrame.ScrollingFrame.ObjHolder.Mage” - Client - LocalScript:8”