Help in jail command

I am making a jail command , the jail spawns on top of the player’s head for some reason

The code -

local clone = game.ServerStorage:WaitForChild("jail"):Clone()
		local something = game.Players:FindFirstChild(PlayerForFun)
		clone.Archivable = true
		clone.Parent= something.Character	
		
		clone:MoveTo(Vector3.new(something.Character.Head))
		for _,v in pairs(clone:GetChildren()) do
			v.CanCollide = false
			wait(2)
			v.CanCollide = true
			
		end

How do I fix it?

There are no errors btw

1 Like
local clone = game.ServerStorage:WaitForChild("jail"):Clone()
local something = game.Players:FindFirstChild(PlayerForFun)
clone.Archivable = true
clone.Parent= something.Character	

clone:MoveTo(Vector3.new(something.Character.HumanoidRootPart))
for _,v in pairs(clone:GetChildren()) do
	v.CanCollide = false
	wait(2)
	v.CanCollide = true
end

That didnt fix the issue at all ,you just formated the code a little

clone:MoveTo(Vector3.new(something.Character.HumanoidRootPart))

I don’t know the size of the jail/prison.

Well it still didnt fix it all

Does the position of the prison change?

local clone = game.ServerStorage:WaitForChild("jail"):Clone()
local something = game.Players:FindFirstChild(PlayerForFun)
clone.Archivable = true
clone.Parent= something.Character	

clone:MoveTo(Vector3.new(something.Character.Head))
clone:TranslateBy(Vector3.new(0, -4, 0))
for _,v in pairs(clone:GetChildren()) do
	v.CanCollide = false
	wait(2)
	v.CanCollide = true
end

Yes I just added .CFrame after humanoidRootPart and then it moved but above the head

This fixed it! What does TranslateBy do?

Shifts a model’s position by a given Vector3 value while maintaining the current orientation of the model.

https://developer.roblox.com/en-us/api-reference/function/Model/TranslateBy

Wait actually I moved from the posittion I was spawning and testing it, The jail doesn’t move from where it was in workspace

local clone = game.ServerStorage:WaitForChild("jail"):Clone()
local something = game.Players:FindFirstChild(PlayerForFun)
clone.Archivable = true
clone.Parent= something.Character	
for _,v in pairs(clone:GetChildren()) do
	v.CanCollide = false
	wait(2)
	v.CanCollide = true
end
clone:MoveTo(Vector3.new(something.Character.Head))
clone:TranslateBy(Vector3.new(0, -4, 0))

Then you should move the prison after it becomes collidable.

It doesn’t move from its original position in workspace

local clone = game.ServerStorage:WaitForChild("jail"):Clone()
local something = game.Players:FindFirstChild(PlayerForFun)
clone.Archivable = true
clone.Parent = something.Character	
clone:MoveTo(something.Character.Head.Position)
clone:TranslateBy(Vector3.new(0, -4, 0))
for _,v in pairs(clone:GetChildren()) do
	v.CanCollide = false
	wait(2)
	v.CanCollide = true
end

I see what you mean now.

Yea it still doesn’t move form its original position

local players = game:GetService("Players")
local player = players.LocalPlayer or players.PlayerAdded:Wait()
task.wait(5)
local clone = game.ServerStorage:WaitForChild("Model"):Clone()
clone.Archivable = true
clone.Parent = player.Character	
clone:MoveTo(player.Character.Head.Position)
clone:TranslateBy(Vector3.new(0, -3, 0))

This is working for me.
Proof:
https://gyazo.com/1dea42dc78c35f4ec2798ac23a9f49fc

Ok ty :slight_smile: it works now tytytytytyt

local players = game:GetService("Players")
local player = players.LocalPlayer or players.PlayerAdded:Wait()
task.wait(5)
local clone = game.ServerStorage:WaitForChild("Model"):Clone()
clone.Archivable = true
clone.Parent = player.Character	
clone:MoveTo(player.Character.HumanoidRootPart.Position)

This actually works even better.