I have a script that if you touch it and you’re not a certain rank in a certain group you will then be teleported to a part, the only issue is that when you touch the part with the script in it then it sometimes doesn’t always work smoothly, example below.
You can see in the video that if you touch the part at a certain angle while holding the W key it will be glitchy https://streamable.com/bl44e3
Disable collisions on the teleporting parts? Looks like it may be an issue of the humanoid attempting to scale the part since it’s below their stepheight.
Alright, perhaps add a cooldown between times it can teleport? My only other thought without seeing the code is that the .Touched event is registering multiple parts belonging to the character and is attempting to teleport the character multiple times. May be as simple as adding a debounce when touched, teleport the player, wait a second then release the debounce.
local GroupId = 0 -- (ID of the Group)
local MinRank = 1 -- (Min Rank - Lowest Staff Rank)
game.Players.PlayerAdded:Connect(function(plr)
if plr:GetRankInGroup(GroupId) >= MinRank then
script.Parent:Destroy()
else
script.Parent.Touched:Connect(function(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild("HumanoidRootPart") then
hit.Parent.HumanoidRootPart.Position = game.Workspace.Teleport.Position
end
end)
end
end)
local GroupId = 0 -- (ID of the Group)
local MinRank = 1 -- (Min Rank - Lowest Staff Rank)
local debounce = false--initialize a debounce boolean outside of the function, somewhere the function can reference
game.Players.PlayerAdded:Connect(function(plr)
if plr:GetRankInGroup(GroupId) >= MinRank then
script.Parent:Destroy()
else
script.Parent.Touched:Connect(function(hit)
if debounce then return end--Check first if debounce is released, else quit the function here
if hit and hit.Parent and hit.Parent:FindFirstChild("HumanoidRootPart") then
debounce = true--If the debounce is released, lock it here
hit.Parent.HumanoidRootPart.Position = game.Workspace.Teleport.Position
task.wait(1)--wait one second before release
debounce = false--release it again
end
end)
end
end)
The idea here is that consequent events within that 1 second window will return themselves, so they don’t teleport the player multiple times. You might also benefit using :SetPrimaryPartCFrame() on the character
Okay, I’ve replicated the idea in studio myself and have had luck writing this script:
local debounce = false
script.Parent.Touched:connect(function(hit)
if debounce then return end
if hit.Parent:FindFirstChild("Humanoid") then
debounce = true
hit.Parent:SetPrimaryPartCFrame(workspace.Teleport.CFrame + Vector3.new(0, hit.Parent.Humanoid.HipHeight, 0))
task.wait(1)
debounce = false
end
end)
This is a script parented to a part in workspace which I think is how you’ve done it. Both parts are anchored, CanCollide false. I didn’t do the rank fetching part but you can add that in