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

How to get a specific player's character from their player?

I'm trying to make a script that will "holster" a fake version of a weapon, welding it to their body when they unequip it. I can't "get" the character to establish a weld. Does anyone have a solution for this?


tool = script.Parent
real = tool.Handle
fake = real:Clone()
backpack = tool.Parent
player = backpack.Parent
name = player.Name

character = -- player character?
attachpoint = character:FindFirstChild("LowerTorso")

fake.Parent = character
fake.Position = attachpoint.Position
fake.Orientation = attachpoint.Orientation

weld = Instance.new("Weld")

weld.Part0 = attachpoint
weld.Part1 = fake

Thank you in advance.

4 comments

0

the parent of the backpack.. right?

0

yea

1

player.Character?

1 answer

weld = Instance.new("Weld")

weld.Parent = game.Players.Localplayer.Character
weld.Part0 = attachpoint
weld.Part1 = fake

or if you would rather the parenting to not be as that you can change it as

weld = Instance.new("Weld",game.Players.Localplayer.Character)

That should work.

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