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

This script is not teleporting the player like it should how do I fix this?

So I am trying to make it so that there is an area where cheaters are teleported to but for some reason it is not teleporting me. This is a local script that is in the StarterPlayerScripts folder. Also, there is a bool value in the player to see if it is true or false.

while true do
	wait()
	local player = script.Parent.Parent
	local character = player.Character
	
	if player.IsBanned == true then
		character.Head.CFrame = CFrame.new(9.605, 9.232, 124.862)
	end
end

4 comments

0

Did you try teleport the HumanoidRootPart instead? Also I usually teleport a player to a part and not a specific location. If you are gonna teleport the player by part, add 5 studs so player doesn't get stuck in part.

0

Why is it a local script??? Make it a server script.

0

if player.IsBanned.Value == true then

0

it has to be a local script

2 answers

✓ Accepted answer

LocalScript

while true do
	wait()
	local player = script.Parent.Parent
	local character = player.Character
	local isban = player:WaitForChild("IsBanned")

if isban.Value == true then
		character:SetPrimaryPartCFrame(CFrame.new(9.605, 9.232, 124.862))
	end
end

ISSUES

A. You indexed "IsBanned" but not its Value Property

B. You can move the player's character (since it's a model) using :SetPrimaryPartCFrame()

C. While loops can break if the check you're using is not loaded into the player yet, so make sure pre-define / wait for it

3 comments

0

That's not calling IsBanned.

0

it is

0

No. It is not. Try executing this: player.IsBanned() it won't work. It will say invalid number of arguments or something because of __namecall.

Teleport HumanoidRootPart, works like a charm. Also all anti cheating scripts should be on server, since, you know, cheaters are local and in theory could exploit any local script.

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