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

I am creating a wereld constaint but the part1 and part0 wont work how to fix this issue?

--// Varibles \\--
local repStorage = game:GetService("ReplicatedStorage")
local ActivateKaguneEvent = repStorage:WaitForChild("ActivateKakune")

local function ActivateKagune(plr)
	local HumanoidRootpart = plr.Character
	local NewKagune = Instance.new("Part",workspace)
	NewKagune.BrickColor = BrickColor.new("Really red")
	NewKagune.Anchored = false
	NewKagune.CanCollide = true
	NewKagune.Position = Vector3.new(0,2,0.5)
	local NewWereld = Instance.new("WeldConstraint",NewKagune)
	NewWereld.Part1 = HumanoidRootpart
	NewWereld.Part0 = NewKagune
end

ActivateKaguneEvent.OnServerEvent:Connect(ActivateKagune)

1 answer

Problem:

  • You made the weld's Part1 a model. It has to be a part.

Solution:

  • Change the HumanoidRootpart variable to plr.Character.HumanoidRootPart as it actually is the HumanoidRootPart.

Recommendations:

  • Don't use the second argument of Instance.new() as it is inefficient and slow. Instead, set the parent by doing Part.Parent = parent.

Fixed Script:

--// Varibles \\--
local repStorage = game:GetService("ReplicatedStorage")
local ActivateKaguneEvent = repStorage:WaitForChild("ActivateKakune")

local function ActivateKagune(plr)
    local HumanoidRootpart = plr.Character.HumanoidRootPart

    local NewKagune = Instance.new("Part")
    NewKagune.BrickColor = BrickColor.new("Really red")
    NewKagune.Anchored = false
    NewKagune.CanCollide = true
    NewKagune.Position = Vector3.new(0,2,0.5)
	NewKagune.Parent = workspace

    local NewWereld = Instance.new("WeldConstraint")
    NewWereld.Part1 = HumanoidRootpart
    NewWereld.Part0 = NewKagune
	NewWereld.Parent = NewKagune
end

ActivateKaguneEvent.OnServerEvent:Connect(ActivateKagune)

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