Hello! How can I insert a model that attaches to a player’s UpperTorso R15?
You can try welding the model onto the torso
I tried but it didn’t work, I don’t know if I’m doing it wrong hmm
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GuitarModel = ReplicatedStorage:WaitForChild("GuitarModel")
local function OnPlayerAdded(player)
print("A player has connected")
task.wait(1) -- Wait a second for the character to load
local character = player.Character
if character then
local attachment = Instance.new("Attachment")
attachment.Parent = character.UpperTorso
attachment.Name = "GuitarAttachment"
local guitar = GuitarModel:Clone()
guitar.Parent = attachment
guitar.Anchored = true
-- Welds the model to the UpperTorso
local welding = Instance.new("Weld")
welding.Part0 = guitar
welding.Part1 = character.UpperTorso
welding.C0 = CFrame.new(0, 0, 0)
welding.C1 = CFrame.new(0, 0, 0)
welding.Parent = guitar
print("The guitar has been placed on the player's UpperTorso")
else
print("The player's character has not yet loaded")
end
end
game.Players.PlayerAdded:Connect(OnPlayerAdded)
Instead of using a Weld, use a WeldConstraint,
Basically change this
local welding = Instance.new("Weld")
welding.Part0 = guitar
welding.Part1 = character.UpperTorso
welding.C0 = CFrame.new(0, 0, 0)
welding.C1 = CFrame.new(0, 0, 0)
welding.Parent = guitar
into this
local welding = Instance.new("WeldConstraint")
welding.Part0 = guitar
welding.Part1 = character.UpperTorso
welding.Parent = guitar
What is the difference? (I seriously don’t know)
This post does well explaining it
well… i tried but still dont work…
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GuitarModel = ReplicatedStorage:WaitForChild("GuitarModel")
local function OnPlayerAdded(player)
player.CharacterAdded:Wait() -- Wait for the character to load
local character = player.Character
local upperTorso = character:WaitForChild("UpperTorso") -- Ensure UpperTorso exists
local guitar = GuitarModel:Clone()
local weld = Instance.new("WeldConstraint")
weld.Part0 = guitar.Handle -- Assuming "Handle" is the part to weld
weld.Part1 = upperTorso
weld.Parent = guitar -- Parent the weld to the guitar
guitar.Parent = character -- Parent the guitar to the character
end
game.Players.PlayerAdded:Connect(OnPlayerAdded())
Mind telling me what’s not working? Like is the entire thing just falling apart or just not appearing at all?
Thanks!
Trying to reach character minimum bleh
It causes me that error, it’s like its not getting the player :c
Try changing this line of code game.Players.PlayerAdded:Connect(OnPlayerAdded())
into this
game.Players.PlayerAdded:Connect(function(plr)
OnPlayerAdded(plr)
end)
Not sure this’ll do anything. Also make sure to weld the Blade to the Handle too, if it isn’t already welded
Look, I just did something similar and it doesn’t work either, I really don’t understand the reasons :C
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GuitarModel = ReplicatedStorage:WaitForChild("GuitarModel"):Clone()
game.Players.PlayerAdded:Connect(function(player)
-- Print the player's name when they join
print("Player added:", player.Name)
-- Wait for the player's character to load
player.CharacterAdded:Wait()
-- Print the player's character name when it loads
print("Character loaded for player:", player.Character.Name)
-- Get the player's character
local character = player.Character
-- Check if the character has an UpperTorso part
local upperTorso = character:WaitForChild("UpperTorso")
if upperTorso then
-- Print that the UpperTorso was found
print("UpperTorso found:", upperTorso)
else
-- Print that the UpperTorso was not found
print("UpperTorso not found")
end
-- Clone the guitar model
local guitar = GuitarModel:Clone()
-- Print that the guitar was cloned
print("Guitar model cloned")
-- Create a WeldConstraint between the guitar and the player's UpperTorso
local weld = Instance.new("WeldConstraint")
weld.Part0 = guitar.Handle
weld.Part1 = upperTorso
weld.Parent = guitar.Handle.Blade
-- Print that the WeldConstraint was created
print("WeldConstraint created and parented to guitar")
-- Parent the guitar to the player's character
guitar.Parent = character
-- Print that the guitar was attached to the player's character
print("Guitar attached to character")
end)
Try moving this local GuitarModel = ReplicatedStorage:WaitForChild("GuitarModel")
into the function. If that doesn’t do anything, then I’m stumped.
Why couldn’t you just do
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
--All your code here
end)
end)
I don’t know how well this would work, but it’s worth a shot.
I tried it and it didn’t work…
I tried it also and it didn’t work
guitar model appear there
My best guess it that you weld constraint the blade to the handle, then maybe use this code??
game.Players.PlayerAdded:Connect(function(plr)
local weld = Instance.new(“WeldConstraint”)
local workspaceplayer = workspace:FindFirstChild(plr.Name)
weld.Part0 = – handle
weld.Part1 = workspaceplayer.UpperTorso
end)
make sure the parts arent anchored
when connecting a function variable to an event, remove the parentheses because using the parentheses will make the function run, while without the paretheses is returning the assigned function to the variable
basically changing this
to this
game.Players.PlayerAdded:Connect(OnPlayerAdded)