https://gyazo.com/7af5f08fb52279429053f5527ad0377e
local axe = "Draco Axe" local price = 30 local currency = "Gems" script.Parent.ClickDetector.MouseClick:Connect(function(plr) wait() local Gui = game.ServerStorage.limitedEditionGui Gui.Axe.Value = axe Gui.Price.Value = price Gui.Currency.Value = currency Gui.Parent = plr.PlayerGui end)
Try to put the GUI in ReplicatedStorage. and on Click this not clone the gui. only set the parent. for this you need to clone. add :Clone()
after limitedEditionGui
:
local Gui = game.ReplicatedStorage.limitedEditionGui:Clone() -- I changed the location to ReplicatedStorage.
here is fixed script:
-- ServerScript(Script) -- local axe = "Draco Axe" local price = 30 local currency = "Gems" script.Parent.ClickDetector.MouseClick:Connect(function(plr) wait() local Gui = game:GetService("ReplicatedStorage").limitedEditionGui:Clone() -- Location of the GUI / and changed the GUI to ReplicatedStorage. / Added :Clone() Gui.Axe.Value = axe Gui.Price.Value = price Gui.Currency.Value = currency Gui.Parent = plr:WaitForChild("PlayerGui") -- Added WaitForChild() end)
Use ServerScript(Script) for this.
This error only happens if you change the location of an item immediately after it is created. to solve this is just clone.
If I am wrong you can correct me in the comments i will edit the answer.
Wiki pages:
Hope it helped :)
Errors? tell-me on comments.
local axe = "Draco Axe" local price = 30 local currency = "Gems" script.Parent.ClickDetector.MouseClick:Connect(function(plr) wait() local GuiClone = game:WaitForChild("ServerStorage"):FindFirstChild("limitedEditionGui"):Clone() --Changed Gui:WaitForChild("Axe").Value = axe Gui:WaitForChild("Price").Value = price Gui:WaitForChild("Currency").Value = currency Gui.Parent = game.StarterGui --Added end)
U should use :Clone()
if u are trying to put the Gui in Player's Gui.
Also
Gui:WaitForChild("Axe").Value = axe Gui:WaitForChild("Price").Value = price Gui:WaitForChild("Currency").Value = currency
U shouldnt try to use Guis to label the Name of the Axe, Price or Currency.
Use a TextLabel
for the Name of the axe and TextButton
for the price(30 Gems) instead so that when the Gui is cloned into the Player's Gui, it is already there and so u wont have to change anything.
Reason for TextButton
is because u can just put a LocalScript
, which is included in the Gui when its cloned, into the TextButton
and when a player tries to buy the axe, he/she can just click the TextButton
and buy it. Also, with TextButton
, u can label the price of the axe as well.
IMPORTANT [EDIT]
Also dude u can just put the Gui into StarterGui
straight, so when the player spawns, u dont need to clone anything from ServerStorage
and it will be in Player's Gui, just change the Value
to TextLabel
and TextButton
.
I hope this helps!
If theres any error, comment below.