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

How do I clone something from serverstorage to localplayer's torso?

I know how to clone and what it is but i haven't learned Vector3 or implementing positions into scripts. I've tried:

script.Parent.MouseButton1Click:connect(function()
	game.ServerStorage.toolcrate:clone().Parent = game.Workspace
game.Workspace.Part:MoveTo(game.Players.LocalPlayer.Character.Torso.Position)

end)

2 answers

I would just change the clone's CFrame to your Torso's CFrame instead of using MoveTo.

script.Parent.MouseButton1Click:connect(function()
    game.ServerStorage.toolcrate:clone().Parent = game.Workspace
game.Workspace.Part.CFrame = game.Players.LocalPlayer.Character.Torso.CFrame

end)

In case you don't know, CFrame is basically a data type that represents position and orientation.

3 comments

0

I've change "Torso" to "UpperTorso" because this game is R15 and upon testing output says: Cframe is not a valid member of Model

0

But, it does spawn the crate in workspace.

0

the f in CFrame is capital, not lowercase. If it still doesn't work, try replacing CFrame with Position. Sorry for the late response.

First thing you should do, is always use caps whenever needed, so “:Connect“over “:connect”. and :Clone over “:clone”. those methods should not be used at ALL. that is why it errors. so do this. I also see you’re using the “ServerStorage” to store something, well don’t. Why? Because ServerStorage items can ONLY be accessed from Server Scripts. Want something that can be on both the server AND client? (so Local scripts can access?) Then check out ReplicatedStorage. And PLEASE use GetService when you want to get a service. Indexing a service (game.ServiceName) like that, there is NO guarantee that service is called that. Example, the “RunService” (ClassName) service is called “Run Service”, so upon indexing it as (game.Run Service) wait...that doesn’t work...(game[“Run Service”]) UGH. You get those square brackets...

Local Script in a TextButton

local plr = game:GetService(“Players”).LocalPlayer
local crateClone  = game:GetService(“ReplicatedStorage”).toolcrate:Clone()

script.Parent.MouseButton1Click:Connect(function()
    crateClone.Parent = game:GetService(“Workspace”)
    game:GetService(“Workspace”).Part.CFrame = plr.Character.UpperTorso.CFrame
end)

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