I’m trying to get my UI to clone everytime “x” object is clicked, but it clones the UI only once.
I’m new to coding with Non-Experimental, so I’m hoping this is just something I’m easily overlooking. Thanks.
Edit: I have it so the other UI will automatically remove after 5 seconds, once I try and clone it again after 5 seconds, it won’t clone.
local ui = game.ReplicatedStorage:WaitForChild("SkeletonUi")
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
if not plr.PlayerGui:FindFirstChild("SkeletonUi") then
ui:Clone().Parent = plr.PlayerGui
end
end)
It is a standard Script and Game is Non-Experimental.
It’s only cloning the GUI once because you are cloning it if it doesn’t exist in the PlayerGui and then parenting that clone in the PlayerGui, which means the next check will fail.
Seems to me that the if statement is checking if the UI already exists before placing another one. Did you remove the UI before attempting to place another?
Strange, did you try using print on each scope to see about where the code stops? I’m guessing the if statement so start there. Print is fairly solid for debugging.
Alright, so is the UI removed locally or globally? I think the problem may be that the server still sees it as existing when for the set client, it doesn’t.
Yes, I believe that you’re only removing it for the client, rather than the server as well, that’s how FE works after all.
Edit: Not to be too confusing, but essentially, if something is done through a localscript, then it will only be applied to that client, while a regular script, is ran on the server, and thus replicated to most clients through the server. Proper replication is done by handling both of these things to put less stress on both the client and the server.