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 4 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

01local Players = game:GetService("Players")
02local player = Players.LocalPlayer
03local mouse = player:GetMouse()
04local Object = game.ServerStorage.Dot
05local copy = Object:Clone()
06 
07 
08mouse.Button1Down:Connect(function()
09    copy = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame
10    copy.Position = UDim2.new(0,mouse.X - 10, 0,mouse.Y + 25 )
11end)

2 answers

Log in to vote
0
Answered by 4 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

01local Players = game:GetService("Players")
02local player = Players.LocalPlayer
03local mouse = player:GetMouse()
04local Object = game.ServerStorage.Dot
05 
06 
07mouse.Button1Down:Connect(function()
08    local copy = Object:Clone()
09    copy.Parent = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame
10    copy.Position = UDim2.new(0,mouse.X - 10, 0,mouse.Y + 25 )
11end)

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 4 years ago
Edited 4 years ago

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

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

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

1local copy = Object:Clone()

into function.

Answer this question