I am trying to make a billboard gui that has a button so I put it in player gui. in my script, I’m trying to clone it but it is not doing that and I don’t know what to do.
-- some of the script
function buildings.new(creator: Player, cframe: CFrame)
return setmetatable({
creator = creator,
gui = creator.PlayerGui:WaitForChild("Object Gui"):Clone(), -- not cloning
model = newModel(logModel, creator.TeamColor.Color, cframe)
}, buildings)
end
function buildings:init()
local creator: Player = self.creator
self.gui.Enabled = true
self.gui.Adornee = self.model.Log
self.money = 0
self.gui.Main["Name & money"].Text = string.format("%s's %s that gained $%d", self.creator.Name, self.model:GetAttribute("name"), self.money)
local btn: TextButton = self.gui.Main.Sell
btn.Text = string.format("Sell for $%d", self.model:GetAttribute("price") * 0.8)
coroutine.wrap(function()
while task.wait(self.model:GetAttribute("waitTime")) and self.model do
self:increase()
end
end)()
self.gui.Main.Remote.OnServerEvent:Connect(function()
self:sell()
end)
print("started")
end
on play:
(its not cloning or setting the adornee)
there are no errors so im confused and i hope this is enough for someone to help
I renamed “creator” to “player” in the module script
here is the server script:
local mod = require(script.Parent.Buildings)
game.Players.PlayerAdded:Connect(function(player)
local m = mod.new(player, CFrame.new(-10, 0.75, 0))
m:init()
end)
Billboard guis are for rendering a 2d image in the 3d workspace environment. If you were to use a screengui you could add it to the player GUI during runtime.
And then the local script and button would work.
I’m a little confused as to what specifically you want to achieve.
If you want a billboard to pop up on a part, use a billboardGui and parent it to the part, but scripts will need to be serverside.
If you want a button to appear on the player GUI simply placing a screengui into starter characterscripts will do this when the character loads and run local scripts.
If you want an event to add the button to the player GUI, then clone a screengui from serverstorage/replicated storage to the player GUI, and this will let you use local scripts as soon as it is parented there.
I am trying to make the billboard gui cloned so I can have multiple with the building.new. The reason it is set in the player-gui is so I can have buttons to work (which does not work on places like workspace, because of local scripts only able to be in player-gui, player-tools etc).
Ok, thanks, so if you:
Change the billboardgui to a screengui and put it in replicated storage.
When you run building.new clone the screengui and parent it to the player GUI.
This should give you the effect you want. Local scripts will work once cloned and reparented.
if you wanted to have multiple screengui at the same time they would overlap, so might be better to clone a frame and put it into a screengui with preset UI layouts