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

Can someone help me fix jail teleport script dot dot dot?

script.Parent.Touched:connect(function(hit)
	local p = game.Players:GetPlayerFromCharacter(hit.Parent).Folder.JailBreak
	p.Value = p.Value + 1
	if p.Value == 1 then
		(hit.Parent).Torso.CFrame = CFrame.new(Vector3.new(-7.467, 3.2, 19.129))
		wait(4)
       (hit.Parent).Torso.CFrame = CFrame.new(Vector3.new(0, 50, 0))
	end
end)

This a script within a "JailTool". when someone hits someone else with this stick, they'll get sent to jail for four seconds, then teleport back.

How do I teleport them back from jail? I'm not sure what to do.

1 answer

✓ Accepted answer

If you want to teleport them back, simply log the Torso's CFrame prior to teleporting. Revert it to this CFrame after the wait :D

Note: You should probably check to see if the player actually exists before trying to index Folder.JailBreak, so you don't come up with a nil value

script.Parent.Touched:connect(function(hit)
	local p = game.Players:GetPlayerFromCharacter(hit.Parent)
	if p then --Does the player exist?
		local val = .Folder.JailBreak
		va,.Value = val.Value + 1
		if p.Value == 1 then
			local torso = hit.Parent.Torso
			local before = torso.CFrame --log it!
			torso.CFrame = CFrame.new(-7.467, 3.2, 19.129)
			wait(4)
			torso.CFrame = before --revert it!
		end
	end
end)

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