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

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

Asked by 6 years ago
Edited 6 years ago

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?

01tool = script.Parent
02real = tool.Handle
03fake = real:Clone()
04backpack = tool.Parent
05player = backpack.Parent
06name = player.Name
07 
08character = -- player character?
09attachpoint = character:FindFirstChild("LowerTorso")
10 
11fake.Parent = character
12fake.Position = attachpoint.Position
13fake.Orientation = attachpoint.Orientation
14 
15weld = Instance.new("Weld")
16 
17weld.Part0 = attachpoint
18weld.Part1 = fake

Thank you in advance.

0
the parent of the backpack.. right? DinozCreates 1070 — 6y
0
yea NEXIUS10 13 — 6y
1
player.Character? DinozCreates 1070 — 6y

1 answer

Log in to vote
0
Answered by
danglt 185
6 years ago
1weld = Instance.new("Weld")
2 
3weld.Parent = game.Players.Localplayer.Character
4weld.Part0 = attachpoint
5weld.Part1 = fake

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

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

That should work.

Ad

Answer this question