0

# why is localscript not cloning to character?

Edited 13 days ago

basically im trying to parent this clone of a localscript that is parented to a script in serverscriptservice to the player's character

but when i play the game the localscript wasnt there in the character model but the output printed ok which means it did work so i dont know where it went

local Seat = workspace.Model.Seat
if Child:IsA("Weld") and Child.Name == "SeatWeld" then
local Player = game.Players:GetPlayerFromCharacter(Child)
local CloneScriptChild = script.LocalScript:Clone()
CloneScriptChild.Parent = Player print("OK!")

Seat.ChildRemoved:Connect(function(Child)
CloneScriptChild:Destroy() print("NOOOOOOOOOOOOOOOO")
end)
end
end)


i dont know if im just being stupid or not

0
When the player sits in the seat the child that is a weld not the player object realchricrocgamer 0 — 13d
0
clarifying above, the player is not parented to a seat when they sit in it, instead what's parented to the seat is a weld which attaches the player's humanoidrootpart to the seat BrimoireGrimoire 11 — 13d
0
how do i fix it tho? proROBLOXkiller5 41 — 13d
0
see my answer i posted BrimoireGrimoire 11 — 13d

0
Edited 13 days ago

as in my comment, welds are parented to the seat, not player objects themselves, you have a check for if it's a weld, but then immediately try to do game.Players:GetPlayerFromCharacter(Child), but since Child is a weld, Player then becomes nil since it couldnt find a player, and in the following statement CloneScriptChild.Parent = Player you just parent the script to nil, effectively removing it. you could instead,

• look at the parents of Part0 and Part1 of the weld and get the player through GetPlayerFromCharacter that way
• :Connect to Seat:GetPropertyChangedSignal("Occupant"), since the seat's Occupant property is set to the humanoid of the player currently sitting in it, retrieving the player object is then trivial
0
i dont get what you mean by parents of part0 and part1 of the weld. all i know is weld is parented to seat which im assuming part0 is a seat proROBLOXkiller5 41 — 13d
0
wait i understand what part0 and part1 is now but im still having a hard time piecing things together proROBLOXkiller5 41 — 13d
0
Edited 13 days ago

fixed it

local Seat = workspace.Model.Seat
if Child:IsA("Weld") and Child.Name == "SeatWeld" then
local Character = Child.Part1.Parent
local Player = game.Players:GetPlayerFromCharacter(Character)--(child.Part1[HumanoidRootPart].Parent)
local CloneScriptChild = script.LocalScript:Clone()
CloneScriptChild.Parent = Player.Character print(Child.Part1)

Seat.ChildRemoved:Connect(function(Child)
CloneScriptChild:Destroy() print("NOOOOOOOOOOOOOOOO")
end)
end
end)

0
this is the answer proROBLOXkiller5 41 — 13d