local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() local debounce = false Mouse.KeyDown:connect(function(key) if key == "p" and not debounce then debounce = true local RinkakuModel = game.ReplicatedStorage.WorkspaceRinkakuModel:Clone() --Assuming the model is now in ReplicatedStorage local w = Instance.new('Weld') w.Part0 = RinkakuModel.PrimaryPart w.Part1 = Player.Character.Torso w.Parent = RinkakuModel.PrimaryPart w.C0 = CFrame.new(0, 0, 0) RinkakuModel.Parent = Player.Character RinkakuModel:MakeJoints() RinkakuModel.Name = Player.Name end end)
It should weld RinkakuModel's primary part to my torso when I press P but instead it spawns where it was put into ReplicatedStorage. Help me get it on my torso please? The script is a localscript and "WorkspaceRinkakuModel" is in Replicated Storage (Despite the name)
Just change the Models's PrimatryPart CFrame to your torso. Assuming that the model is about the size of the torso. To change the CFrame of a model do :SetPrimaryPartCFrame()
local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() local debounce = false Mouse.KeyDown:connect(function(key) if key == "p" and not debounce then debounce = true local RinkakuModel = game.ReplicatedStorage.WorkspaceRinkakuModel:Clone() --Assuming the model is now in ReplicatedStorage local w = Instance.new('Weld') w.Part0 = RinkakuModel.PrimaryPart w.Part1 = Player.Character.Torso w.Parent = RinkakuModel.PrimaryPart w.C0 = CFrame.new(0, 0, 0) RinkakuModel.Parent = Player.Character RinkakuModel:SetPrimaryPartCFrame(Player.Character.Torso.CFrame*CFrame.Angles(math.rad(Player.Character.Torso.Rotation.X),math.rad(Player.Character.Torso.Rotation.Y),math.rad(Player.Character.Torso.Rotation.Z))) RinkakuModel:MakeJoints() RinkakuModel.Name = Player.Name end end)
Hope it helps!
Game Script in ServerScript Service
game.ReplicatedStorage:FindFirstChild("RinkakuModel").PrimaryPart = game.ReplicatedStorage:FindFirstChild("RinkakuModel").Primary local function makewelds(model,base) local b = base or model.PrimaryPart for i,v in pairs(model:GetChildren()) do if #v:GetChildren() > 0 then coroutine.resume(coroutine.create(makewelds),v,b) end if v:IsA("BasePart") and v ~= b then local w = Instance.new("Weld",b) w.Part0 = b w.Part1 = v w.C0 = v.CFrame - b.Position end end end makewelds(game.ReplicatedStorage:FindFirstChild("RinkakuModel"))
Local Script in StarterGui or StarterPack
local player = game:GetService("Players").LocalPlayer local mouse = player:GetMouse() local RinkakuModel = game.ReplicatedStorage:FindFirstChild("RinkakuModel") local m m = mouse.KeyDown:connect(function(key) if key == "p" then m:disconnect() local clone = RinkakuModel:Clone() local w = Instance.new("Weld",clone.PrimaryPart) w.Part0 = clone.PrimaryPart w.Part1 = player.Character:FindFirstChild("Torso") clone.Parent = player.Character end script:Destroy() end)