Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Moving a model from ServerStorage to Workspace?

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!

2 comments

0

You can find the answer to your question with some simple google searches. What is up with these types of questions lately?

0

plz du sum research C; thanx

2 answers

✓ Accepted answer

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.

script.Parent.ClickDetector.MouseClick:Connect(function(player)
	local clone = game:GetService("ServerStorage")[COMP]:Clone()
	clone.Parent = workspace
end)

1 comment

0

Thank you!

This discussion is preserved as it was. New answers, comments, and votes are closed.