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

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

Asked by 6 years ago
Edited 6 years ago

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

Log in to vote
0
Answered by
ax_gold 360 Moderation Voter
6 years ago
Edited 6 years ago

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.

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 Lord_Nermall 1 — 6y
0
But, it does spawn the crate in workspace. Lord_Nermall 1 — 6y
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. ax_gold 360 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

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)

Answer this question