How to fix this?

  1. What do you want to achieve? Make a part be the parent of the player.

  2. What is the issue? The part spawns at a random place of the map instead the player’s character and i don’t know how to fix this.

  3. What solutions have you tried so far? I tried to anchor the part but it din’t worked.

Script:

local event = game.ReplicatedStorage:WaitForChild("PartEvent")

event.OnServerEvent:Connect(function(player)
	local char = player.Character

local pt1 = Instance.new("Part",char["HumanoidRootPart"])
	pt1.Name = "beam1"
	pt1.Anchored = true
	pt1.Transparency = 1
	pt1.CanCollide = false
	pt1.CanQuery = false
	pt1.Size = Vector3.new(4, 1, 2)
	pt1.Orientation = Vector3.new(0, 180, 40)
end)

Why the part spawns at a random place instead the player?

1 Like

Try to rename the char and add a findfirstchild or a waitforchild in humanoidrootpart, maybe it is not loaded

pt1.Position = (where you want it to be for example HumanoidRootPart.Position)

1 Like

Try this

local char = player.Character or player.CharacterAdded:Wait()

it worked, but the part doesn’t follow the player

Alright to make it follow the player you need to put the following code :
local weld = Instance.new(“Weld”)
weld.Parent = (HumanoidRootPart)
weld.Part0 = pt1
weld.Part1 = (HumanoidRootPart)