Textbutton in billboard gui stop working

this is my GUI setup
image
image
the script is fine when I click the gui button,


but when I change the GUI setup for somehow the script stop running
image
image
-no output when i click it
this is my script

local objectgui = script.Parent.Parent.Parent
local TweenService = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(0.1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, true)
local buttonEffect = TweenService:Create(objectgui, tweenInfo, {Size = UDim2.new(3.2, 0, 1.2, 0)})

local alreadyclicked = false

script.Parent.Activated:Connect(function()
	if alreadyclicked == false then
		print("no way")
		alreadyclicked = true
		buttonEffect:Play()
		wait()
		local a = Instance.new("Part")
		a.Size = Vector3.new(1,1,1)
		a.Anchored = true
		a.Transparency = 1
		a.Parent = script.Parent.Parent.Parent.Adornee
		a.CFrame = a.Parent.texture.CFrame:ToWorldSpace(CFrame.new(-1,0.2,-0.5))
		a.CFrame = CFrame.new(a.Position,a.Parent.Position)
		game.Workspace.Camera.CameraType = Enum.CameraType.Scriptable
		game.Workspace.Camera.CFrame = a.CFrame
	end
end)
2 Likes

Well, that’d be because when you change where you put the objects in the explorer, the variables you put in the localscript won’t find it. You have to either keep everything where it is, and if you change where they are, change the variables in the localscript to match their new areas.

but when i change it back, it still not working

Really? Hmm… Is there anything more to the localscript? Or any other scripts/localscripts that work with it to make this all work?

Perhaps try using MouseButton1Click instead of .Activated. Try copy and pasting this in (just comment out the other stuff to not delete anything):

local objectgui = script.Parent.Parent.Parent
local TweenService = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(0.1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, true)
local buttonEffect = TweenService:Create(objectgui, tweenInfo, {Size = UDim2.new(3.2, 0, 1.2, 0)})

local alreadyclicked = false

script.Parent.MouseButton1Click:Connect(function()
	if alreadyclicked == false then
		print("no way")
		alreadyclicked = true
		buttonEffect:Play()
		wait()
		local a = Instance.new("Part")
		a.Size = Vector3.new(1,1,1)
		a.Anchored = true
		a.Transparency = 1
		a.Parent = script.Parent.Parent.Parent.Adornee
		a.CFrame = a.Parent.texture.CFrame:ToWorldSpace(CFrame.new(-1,0.2,-0.5))
		a.CFrame = CFrame.new(a.Position,a.Parent.Position)
		game.Workspace.Camera.CameraType = Enum.CameraType.Scriptable
		game.Workspace.Camera.CFrame = a.CFrame
	end
end)
1 Like

yes, I’m going to try that now

Also, is it meant to only let you click it once and never again? Because you never put “alreadyclicked” back to false, which means you can only click it once, because of the if statement’s condition.

only for once but still it wont work for the first time i click it

Try it without the alreadyclicked part of the script. That way we can pinpoint if the problem is with that part of it or not. Here, I just commented out those parts:

local objectgui = script.Parent.Parent.Parent
local TweenService = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(0.1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, true)
local buttonEffect = TweenService:Create(objectgui, tweenInfo, {Size = UDim2.new(3.2, 0, 1.2, 0)})

--local alreadyclicked = false

script.Parent.MouseButton1Click:Connect(function()
--	if alreadyclicked == false then
		print("no way")
		alreadyclicked = true
		buttonEffect:Play()
		wait()
		local a = Instance.new("Part")
		a.Size = Vector3.new(1,1,1)
		a.Anchored = true
		a.Transparency = 1
		a.Parent = script.Parent.Parent.Parent.Adornee
		a.CFrame = a.Parent.texture.CFrame:ToWorldSpace(CFrame.new(-1,0.2,-0.5))
		a.CFrame = CFrame.new(a.Position,a.Parent.Position)
		game.Workspace.Camera.CameraType = Enum.CameraType.Scriptable
		game.Workspace.Camera.CFrame = a.CFrame
--	end
end)

still not working I don’t why :sweat_smile:

Oh that’s odd… try placing a print() statement before the MouseButton1Click event, to see if the script is even working at all or getting past the variables.

same, still not working :rofl: :rofl:

Oh man, must be something weird going on with the script… did you put a print() at the very beginning of the localscript? Perhaps we could get someone who might have an idea of what’s going on. You might want to copy the contents of that localscript into a new localscript, just in case something’s wrong with it.

yes i, put it before the event

Hmm okay odd. Sorry for the hassle, but could you try putting it in the very beginning of the localscript before anything else? If this doesn’t work then there’s something strange going on, and you’ll want to try moving the code into a new localscript.

yes i already try to put it before anything too, still not work. i also try with new script and still not working. i dont know why maybe this is a bug?

This script is placed inside of ScreenGUI? And if you just had a print statement in the localscript (nothing else) does it work? This could be a problem with the localscript not running in the first place due to where it’s placed.

the script placed inside textbutton
image
(note that i put other gui inside the folder to trigger the script problem) and like that the script not working.

then i only have print statement in the script, and for somehow it work
image
image

Is the billboard GUI part of the workspace, or a Tool?

the billboard is part of player gui