So basically I’m making a merge gems game.
It is based on the hit mobile game genre of merging things.
e.g: you start with a, a + a = b, b + b = c, c + c = d, and so on.
Like this except instead of dragging it shows arrows and you click one and then it moves it (haven’t done the moving yet.)
External Media
Heres a link because it keeps breaking: https://www.mergegems.com/assets/images/gifs/MergeGems-Discover.gif
I want to clone a UI and put it as a child of a model. Simple, right?
Nothing happens, it prints stuff but doesn’t clone the UI at all…
I’ve only tried one thing, which is a script that is supposed to be working.
Here is my code:
MergeSystem (modulescript
-- made by recanman
local merge = {}
local controls = require(script.Controls)
local function showHoverUi(preset, gem)
local hoverUi = game.ReplicatedStorage.Assets.UI.HoverUI:Clone()
hoverUi.Parent = gem
print("hi people") -- this works
hoverUi.MainFrame.MainText.Text = hoverUi.Presets[preset].Value
if (preset == "UpArrow") then hoverUi.ExtentsOffset = Vector3.new(0, 2, 0)
elseif (preset == "DownArrow") then hoverUi.ExtentsOffset = Vector3.new(0, -2, 0)
elseif (preset == "LeftArrow") then hoverUi.ExtentsOffset = Vector3.new(-2.5, 0, 0)
elseif (preset == "RightArrow") then hoverUi.ExtentsOffset = Vector3.new(2.5, 0, 0)
else print("Malformed preset.") end
end
function merge.ShowControls(hole)
local ui = game.ReplicatedStorage.Assets.UI.HoverUI
local gem = hole.Parent:FindFirstChildOfClass("Model")
for name, _ in pairs(controls[hole.Name]) do
showHoverUi(name .. "Arrow", gem)
end
end
return merge
Controls (ModuleScript)
-- made by recanman
local controls = {}
controls.Hole1 = {
Down = true,
Left = true
} controls.Hole2 = {
Down = true,
Right = true,
Left = true
} controls.Hole3 = {
Down = true,
Right = true,
Left = true
} controls.Hole4 = {
Down = true,
Right = true
} controls.Hole5 = {
Up = true,
Left = true
} controls.Hole6 = {
Up = true,
Right = true
} controls.Hole7 = {
Up = true,
Right = true,
Left = true
} controls.Hole8 = {
Up = true,
Right = true,
Left = true
}
return controls
Merge (LocalScript)
-- made by recanman
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local island = game.Workspace:WaitForChild("PlayerFolders"):WaitForChild(plr.Name).Island
local merge = require(game.ReplicatedStorage.Assets.Modules.MergeSystem)
local mtarget
local db
mouse.Move:Connect(function()
if (db == true) then wait() else
db = true
if (mouse.Target ~= nil) then
mtarget = mouse.Target
if (string.lower(mtarget.Name) == "border") then
merge.ShowControls(mtarget.Parent.Parent)
end
end
wait(1)
db = false
end
end)
Any help would be appreciated. Thanks!!