Parts Z Axis Messing Up

Hello Devs,

I’ve ran into a problem with my part spawning script. I wanted to make it so that depending on which “Side” the character its on it would either spawn the part +20 or -20 away on the Z Axis.

It does this thing where instead of being infront of the player when I give it the correct number. It’s like its completely unphased by the number and does it own thing. How could I fix this?

Code:

function FollowPart()
	local Humanoid = Character:WaitForChild('Humanoid')
	local Head = Character:WaitForChild('Head')
	-- Check --
	local Part = Instance.new('Part')
	-- Setup Part --
	Part.Name = 'FollowPart'
	Part.Parent = Character
	Part.Size = Vector3.new(1,1,1)
	Part.Transparency = 1
	Part.Anchored = true
	Part.CanCollide = false
	---- Check --
	if Character:GetAttribute('PartSide','ToBlue') then
		Part.Position = Vector3.new(Head.Position.X,Head.Position.Y,-Head.Position.Z + 20)
	else
		Part.Position = Vector3.new(Head.Position.X,Head.Position.Y,Head.Position.Z + 20)
	end
	-- Setup IKControls --
	Humanoid.ArmControl.Target = Part
	Humanoid.TorsoControl.Target = Part
	-- While Statement --
	while true do
		task.wait()
		Part.Position = Vector3.new(LocalMouse.Hit.X,Part.Position.Y,Part.Position.Z)
		-- Check x2 --
		if CanUpdate then
			-- Sent To Server --
			MainEvent:FireServer('Replicate',Character,Part.Position)
		end
		-- Check --
		if IsSlapping then
			-- Update --
			MouseSpeed = math.floor((Vector2.new(LocalMouse.X,LocalMouse.Y) - LastPosition).Magnitude)
			MSNumber.Text = MouseSpeed
			LastPosition = Vector2.new(LocalMouse.X,LocalMouse.Y)
		end
	end
end

Issue is this if statement

	if Character:GetAttribute('PartSide','ToBlue') then
		Part.Position = Vector3.new(Head.Position.X,Head.Position.Y,-Head.Position.Z + 20)
	else
		Part.Position = Vector3.new(Head.Position.X,Head.Position.Y,Head.Position.Z + 20)
	end

Change your code to this:
if Character:GetAttribute('PartSide') == "ToBlue" then

:GetAttribute() method only accepts one string argument.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.