Help with making a part roll

I’m attempting to make a part roll as it is following my character and it will kill them when the player touches it.

The issue is that the part does roll but it stops when it teleports to the player to follow them.

I tried swapping the tasks around but that didn’t work

Code:

script.Parent.Touched:Connect(function(part)
	local humanoid = part.Parent:FindFirstChild("Humanoid")
	if humanoid then
		humanoid.Health = 0
	end
end)

task.spawn(function()
	while true do
		local turningSpeed = 10
		script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(0, math.rad(turningSpeed), 0)
		wait(0.01)
	end
end)

task.wait(2)
local player = game.Players.ExtremeSteaks
local char = player.Character

while true do
	workspace.Part.CFrame = char.UpperTorso.CFrame:ToWorldSpace(CFrame.new(0,0,5))
	task.wait(0.01)
end

Video:

What seems to be the problem?

2 Likes

Does any errors put out? It might be because the script is exhausted from the while true do.

1 Like

No errors are present in the output.

1 Like

Maybe this?

script.Parent.Touched:Connect(function(part)
	local humanoid = part.Parent:FindFirstChild("Humanoid")
	if humanoid then
		humanoid.Health = 0
	end
end)

task.wait(2)
local player = game.Players.ExtremeSteaks
local char = player.Character

while true do
	workspace.Part.CFrame = char.UpperTorso.CFrame:ToWorldSpace(CFrame.new(0,0,5))
local turningSpeed = 10
	script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(0, math.rad(turningSpeed), 0)
	task.wait(0.01)
end
2 Likes

This is what it ends up like

1 Like

Maybe replace this line with this?

script.Parent.CFrame = CFrame.new(script.Parent.Position) * CFrame.Angles(0, math.rad(turningSpeed), 0)
2 Likes

It just causes the block to stop rotating.

this is what is found in the output
image

2 Likes

I don’t think that has anything to do with the like change though. Did you move the script or changed anything else in the script?

2 Likes

Nope, I did what you said to replace one line with another.

2 Likes

Can I ask what script.Parent is?

2 Likes

The script’s parent is the part that is moving and following the player

2 Likes

I meant it as in like, the same original script from the post. Are there any changes you did since then?

2 Likes

Ball follow - only target once.rbxm (4.3 KB)
Totally it was from Ball then you add it SpecialMesh as Cube. I also modify physic using “BodyAngularVelocity” avoid getting roll too far

Script

local Speed=1.2 -- set 2 It's already powerful

script.Parent.Touched:Connect(function(part)
local humanoid = part.Parent:FindFirstChild("Humanoid")
if humanoid then
humanoid.Health = 0
end
end)

task.wait(2)
--local player = game.Players.ExtremeSteaks
local player = game.Players.Hezt0z
local char = player.Character

while true do
workspace.Part.Velocity=workspace.Part.Velocity-(workspace.Part.Position-char.HumanoidRootPart.Position).unit*Speed
task.wait(0.01)
end
2 Likes