RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"make a script that teleports my character on top of a close character when i press z"
-- Local script local UserInputService = game:GetService('UserInputService') local Players = game:GetService('Players') local player = Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() UserInputService.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.Z then local closestCharacter = nil local closestDistance = math.huge for _, otherPlayer in pairs(Players:GetPlayers()) do if otherPlayer ~= player then local otherCharacter = otherPlayer.Character if otherCharacter then local distance = (character.HumanoidRootPart.Position - otherCharacter.HumanoidRootPart.Position).Magnitude if distance < closestDistance then closestCharacter = otherCharacter closestDistance = distance end end end end if closestCharacter then character.HumanoidRootPart.CFrame = closestCharacter.HumanoidRootPart.CFrame + Vector3.new(0, 5, 0) end end end)