Bezier Tween on character breaking character?

What I am trying to achieve:
I am trying to make a randomized spawn system so that when a player spawns in, a block is created and they are then spawned on that block, and tweened into the gameplay arena.

The issue:
On the client’s end, everything seems to be working fine until you swing your smacker.

image

When you swing, the “DmgPoints” are above the player’s head inexplicably.

This is because on the server’s end, the character is floating sideways above the map.

image

ServerScript:

local BezierTween = require(game:GetService("ReplicatedStorage"):WaitForChild("BezierTweens"))
local Ragdoll = require(game:GetService("ReplicatedStorage"):WaitForChild("RagdollModule"))
local Waypoints = BezierTween.Waypoints

radius = 50

local function getXAndZPositions(r, angle)
	local x = math.sin(math.rad(angle)) * r
	local z = math.cos(math.rad(angle)) * r

	return x, z
end

local function newPart(angle)
	local p = Instance.new("Part", workspace.SpawnPartCache)
	p.Anchored = true
	p.Size = Vector3.new(6, 1, 3)
	
	p.BrickColor = BrickColor.new("Magenta")

	local x, z = getXAndZPositions(radius, angle)
	p.Position = workspace.MidPoint.Position + Vector3.new(x, 15, z)
	p.Orientation = Vector3.new(0, angle, 0)
	
	return p
end

local function Transparencize(Part)
	Part.Anchored = true
	Part.CanCollide = false
	Part.Transparency = 1
end

local Smacker = game:GetService("ReplicatedStorage"):WaitForChild("Smacker")

function onSpawn(Root)
	local SpawnAngle = math.random(0, 360)
	local Part = newPart(SpawnAngle)
	
	task.wait(1)
	Root.Parent:MoveTo(Part.Position + Vector3.new(0, 3, 0))
	task.wait(1)
	Root.Orientation = Part.Orientation
	
	task.wait(3)
	
	local StartPos = Root.Position
	local P2Pos = Root.Position + Vector3.new(0, 10, 0)
	local P3Pos = Part.Position + (Root.CFrame.LookVector * 10)
	local EndPos = Part.Position + (Root.CFrame.LookVector * 10) - Vector3.new(0, 15, 0)
	
	
	local P1 = Instance.new("Part", workspace.SpawnPartCache)
	Transparencize(P1)
	P1.Position = StartPos
	
	local P2 = Instance.new("Part", workspace.SpawnPartCache)
	Transparencize(P2)
	P2.Position = P2Pos
	
	local P3 = Instance.new("Part", workspace.SpawnPartCache)
	Transparencize(P3)
	P3.Position = P3Pos
	
	local P4 = Instance.new("Part", workspace.SpawnPartCache)
	Transparencize(P4)
	P4.Position = EndPos
	
	local waypoints = Waypoints.new(P1, P2, P3, P4)
	local Tween = BezierTween.Create(Root, {
		Waypoints = waypoints,
		EasingStyle = Enum.EasingStyle.Sine,
		EasingDirection = Enum.EasingDirection.In,
		Time = 1,
	})
	Tween:Play()
	
	P1:Destroy()
	P2:Destroy()
	P3:Destroy()
	P4:Destroy()
	
	for i = 1, 10 do
		Part.Transparency += .1
		task.wait(.1)
	end
	Part:Destroy()
	Root.Anchored = false
	Smacker:Clone().Parent = Root.Parent
end

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local Root = Character:WaitForChild("HumanoidRootPart")
		onSpawn(Root)
		Ragdoll:RigPlayer(Character)
	end)
end)

Maybe a late reply, but changing Positions will indeed break a character because Welds won’t move with it. CFrame however will support this. (I don’t know if you already found a fix but I answered because I didn’t see any answer yet :person_shrugging: )

2 Likes

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