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

Model in ServerStorage not cloning to workspace when a gui button is clicked?

Asked by 4 years ago
Edited 4 years ago

I tried searching up how to do it, and still, it won't work. Here is my code.

function leftClick()
game.ServerStorage.freecards:Clone().Parent = workspace
end

2 answers

Log in to vote
2
Answered by 4 years ago
Edited 4 years ago

You’re having the same issue like last time. You made the function but you’re not calling the function. It should also be in a regular script.

local ss = game:GetService("ServerStorage") --this makes serverstorage a variable that you could easily use.

local freecards = ss:WaitForChild("freecards") --this creates an easy reference to the object you’re cloning

function leftClick()
local freecardsclone = freecards:Clone() --clones the object
freecardsclone.Parent = game.Workspace --moves the object to workspace
end

--Now we have to call the function
script.Parent.MouseButton1Click:connect(leftClick) -- Waits until the button is clicked

I haven’t tested this yet but I hope it works.

0
It gave an error "11:22:02.272 - Players.SadWowow21.PlayerGui.ScreenGui.admin.freecard.Script:1: Unexpected Unicode character: U+201c. Did you mean '"'?" Sadwowow21 57 — 4y
0
This is because of the quotations. They needs to be " (upright), this is auto-generated by the Studio. On a different device, such as mobile, this isn’t when using StackEdit. This resulted in “ instead of ". “ can’t be understood by the compiler Ziffixture 6913 — 4y
0
Sorry about that, I was on mobile. Just replace the the quotation marks with your own. XxOPGUYxX1234567 221 — 4y
Ad
Log in to vote
1
Answered by
haba_nero 386 Moderation Voter
4 years ago
Edited 4 years ago

UPDATED ANSWER

You need to use Events. These can transport info between the server and the client. You need to make two scripts. One that will make the event fire, and one that spawns the thing when the event is received. You can read how to do this here: https://developer.roblox.com/ko-kr/articles/Remote-Functions-and-Events

I hope this helps you!

Best,

TheLastHabanero

0
it says " 10:49:17.787 - freecards is not a valid member of ServerStorage" but I put freecards into ServerStorage Sadwowow21 57 — 4y
0
nvm I used a localscript, when I changed it to a script it would not do anything and no errors. Sadwowow21 57 — 4y
0
Ok I know what's wrong. Do game.ServerStorage:FindFirstChild("freecards"):Clone(workspace) haba_nero 386 — 4y
0
same thing, not working with no error. I will try putting it somewhere else. Sadwowow21 57 — 4y
0
Ok. I forgot about one thing. ServerEvents! haba_nero 386 — 4y

Answer this question