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

Moving a model from ServerStorage to Workspace?

Asked by
Cactj -2
6 years ago

Hello! I am having trouble on this script I am working on. I am trying to make a button when upon clicked, it moves a model from ServerStorage to workspace.

function onClicked()
    game.Lighting[COMP]:Clone() =
    game.Workspace
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)`

I understand this is probably dead wrong. Can someone help me point out my mistake and help me with my question?

Thanks!

0
You can find the answer to your question with some simple google searches. What is up with these types of questions lately? T0XN 276 — 6y
0
plz du sum research C; thanx TheeDeathCaster 2368 — 6y

2 answers

Log in to vote
0
Answered by
zblox164 531 Moderation Voter
6 years ago
Edited 6 years ago

Try this:

script.Parent.ClickDetector.MouseClick:connect(function()
    game.ServerStorage.COMP:Clone().Parent = workspace -- This way you only use 1 line.

end)

You could also do this:

local serverstorage = game:GetService("ServerStorage")

script.Parent.ClickDetector.MouseClick:connect(function()
    serverstorage.COMP:Clone().Parent = workspace
end)

If I was you it would depend on what I was doing. If I only needed to do a simple script with a few lines 20 max I would use the first method. If it was a script with hundreds of lines I would go with the second way. Mainly because of the variable. The variable lets me access server storage with just one word.

Ad
Log in to vote
1
Answered by 6 years ago
script.Parent.ClickDetector.MouseClick:Connect(function(player)
    local clone = game:GetService("ServerStorage")[COMP]:Clone()
    clone.Parent = workspace
end)
0
Thank you! Cactj -2 — 6y

Answer this question