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

[SOLVED] Problem with teleporting a player (no errors) Can someone help?

Hello, I really need help with my handcuffs and the scripts in it.

Almost everything works with my handcuffs, the only thing not working is the part where the serverscript teleports the player to their prison cell. I have looked everywhere for an answer, but no luck.

Here is a part of my serverscript:

RemoteEvent.OnServerEvent:Connect(function(player, state, part) -- state == 'Jail' and part == workspace.Player1
	if state == 'Jail' then
		Using = false		
		targetbody.Anchored = false
		workspace:FindFirstChild(part.Name).Humanoid.PlatformStand = false

		local GetPlayer = game.Players:FindFirstChild(part.Name)
		local jailPosition = prisons[math.random(1,#prisons)].Position -- This is the position
		GetPlayer.TeamColor = BrickColor.new("Smoky grey")
		GetPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(jailPosition) -- This is the problem, it works with the commandbar but not in the script

	end
end)

There are no errors, but it won't move the player at all. I have tried using "SetPrimaryPartCFrame"

a part of my Localscript:

local PlayerCuffed -- Equal to workspace.Player1
local Jailing = false
local Using = false
Tool.Unequipped:Connect(function()
	Player.PlayerGui.CuffGui.Enabled = false
	if PlayerCuffed == nil then return end
	Using = false
	if not Jailing then
		RemoteEvent:FireServer('UnCuff', PlayerCuffed)
		PlayerCuffed = nil
	end
end)

CuffGui.Jail.JailRound.JailButton.MouseButton1Down:Connect(function()
	Jailing = true
	local humanoid = Player.Character:FindFirstChildOfClass('Humanoid')
	if humanoid then
		humanoid:UnequipTools()
	end
	RemoteEvent:FireServer('Jail', PlayerCuffed)
	PlayerCuffed = nil
	Using = false
	Jailing = false
end)

Hopefully I can find an answer to this question.

EDIT: I did find an answer look at my answer that I posted to this topic.

3 answers

You defined the new CFrame wrong i think. Do this:

GetPlayer.Character.HumanoidRootPart.CFrame = jailPosition.CFrame

I'm not sure if this works tho, but i don't see another solution.

1 comment

0

The CFrame was defined correctly, but thanks for trying.

I think i know how to fix the position:

(Part of)

  1. Insert the part at the one of prisons

1.5. The Parent is Workspace

  1. Then scroll down until you see the position

  2. Name The Part HandcuffTeleportPart

  3. Then Copy The Position

  4. And Paste to G (Which is in The Script)

  5. Dont Destroy, cause When You Playing it The Handcuff Teleport Part Will Transparent and non-collideable and anchored.

  6. Then The Script (Copy-Paste Or Write, Insert it To Part of the Positions in Your Script)

local HTP = game.Workspace.HandcuffTeleportPart

-- Booleans

HTP.Anchored = true -- Bool
HTP.CanCollide = false -- Bool
HTP.Transparency = 1-- Float


local HandCuff_Tele = Vector3.new(G) -- Replace G with The HandcuffTeleportPart Position
-- Character
GetPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(HandCuff_Tele)

1 comment

0

This just gives no error and does the same as the other solutions.

Found out the problem was with platformstanding.

From roblox api: When true, the Humanoid is in a state where it is free-falling and cannot move.

Therefor I added this to my script:

local GetPlayer = game.Players:FindFirstChild(part.Name) -- part is equal to workspace.Player1
local prisons = workspace.Prison:GetChildren()
local jailPosition = prisons[math.random(1,#prisons)].CFrame

Using = false		
targetbody.Anchored = false
workspace:FindFirstChild(part.Name).Humanoid.PlatformStand = false

GetPlayer.Character.Humanoid.PlatformStanding:Connect(function(isPlatformStanding)
	if not isPlatformStanding then
		part:SetPrimaryPartCFrame(jailPosition)
	end
end)

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