Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I dont know how to copy frames into screen gui?

Asked by 3 years ago

i am trying to make a game were you are clicking to make a frame (very weird) and i am trying to make that it would copy the frame from server storage and paste it into starter gui but it dosent work if u have any solution let me know

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()
local Object = game.ServerStorage.Dot
local copy = Object:Clone()


mouse.Button1Down:Connect(function()
    copy = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame
    copy.Position = UDim2.new(0,mouse.X - 10, 0,mouse.Y + 25 )
end)

2 answers

Log in to vote
0
Answered by 3 years ago

You should put your copy clone variable in the function so every time you click, it clones it instead of cloning ONLY ONCE

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()
local Object = game.ServerStorage.Dot


mouse.Button1Down:Connect(function()
    local copy = Object:Clone()
    copy.Parent = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame
    copy.Position = UDim2.new(0,mouse.X - 10, 0,mouse.Y + 25 )
end)

You also instead of defining copy clone's Parent, you instead redefined the copy variable as an Instance location. Hope that solves your issue! :)

Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Seems like you forgot to add ".Parent" in line 9

copy.Parent = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame

But if u need to copy your object more than once, u have to put

local copy = Object:Clone()

into function.

Answer this question