Humanoid
*Bu içerik, yapay zekâ (beta) kullanılarak çevrildi ve hatalar içerebilir. Sayfayı İngilizce görüntülemek için buraya tıkla.
Humanoid, modellere bir karakterin işlevselliğini veren özel bir nesnedir.Modelin fiziksel olarak etrafında dolaşıp Roblox deneyiminin çeşitli bileşenleriyle etkileşime girebilme yeteneğini verir.Humanoidler daima bir içinde ebeveynliğe sahiptir ve modelin bir montajı olması beklenir ve ; montajın kök kısmının adlandırılması beklenir .Ayrıca, Head adlı bir parçanın karakterin gövdesine doğrudan veya dolaylı olarak bağlanmasını bekler.Varsayılan olarak, Roblox tarafından sağlanan iki resmi karakter kolu vardır, her biri kendi kurallarına sahiptir:
R6
- 6 parça kullanan temel bir karakter yapısı.
- The Head kısmı, Torso adlı bir parçaya bağlanmalı veya Humanoid hemen ölecek.
- Vücut Parçası görünümleri CharacterMesh nesneleri kullanılarak uygulanır.
- Humanoid.LeftLeg ve Humanoid.RightLeg gibi bazı özellikler yalnızca R6 ile çalışır.
R15
- R6'dan daha karmaşık, ancak çok daha esnek ve sağlam.
- Kollar için 15 parça kullanır.
- The Head kısmı, UpperTorso adlı bir parçaya bağlanmalı veya insansız hemen ölecek.
- Vücut Parçası görünümleri doğrudan birleştirilmelidir.
- Humanoit içinde özel NumberValue nesneler kullanarak dinamik olarak ölçeklendirilebilir.
- Humanoid, her bir ekstremitede adlandırılan Vector3Value nesneleri otomatik olarak oluşturur OriginalSize.
- Bir NumberValue, Humanoid'in içine ebeveyn alınır ve takip edilenbiri olarak adlandırılırsa, ölçekleme işlevini kontrol etmek için kullanılacaktır:
- Vücut Derinliği Ölçeği
- Vücut Yüksekliği Ölçeği
- Vücut Genişliği Ölçeği
- Kafa Ölçeği
Kod Örnekleri
This LocalScript makes the camera bobble as the player's character walks around, utilizing both the Humanoid's CameraOffset and MoveDirection. It should be parented inside of the StarterCharacterScripts so that it is distributed into a player's character as expected.
local RunService = game:GetService("RunService")
local playerModel = script.Parent
local humanoid = playerModel:WaitForChild("Humanoid")
local function updateBobbleEffect()
local now = tick()
if humanoid.MoveDirection.Magnitude > 0 then -- Is the character walking?
local velocity = humanoid.RootPart.Velocity
local bobble_X = math.cos(now * 9) / 5
local bobble_Y = math.abs(math.sin(now * 12)) / 5
local bobble = Vector3.new(bobble_X, bobble_Y, 0) * math.min(1, velocity.Magnitude / humanoid.WalkSpeed)
humanoid.CameraOffset = humanoid.CameraOffset:lerp(bobble, 0.25)
else
-- Scale down the CameraOffset so that it shifts back to its regular position.
humanoid.CameraOffset = humanoid.CameraOffset * 0.75
end
end
RunService.RenderStepped:Connect(updateBobbleEffect)
Özet
Özellikler
Karakterin bir engeli mobil bir cihazda oyuncu olarak vurduğunda otomatik olarak atlayıp atmayacağını ayarlar.
Otomatik Döndürme, insanoid'in hangi yöne döneceğini otomatik olarak belirler; hareket ettiği yönde.
Aktifleştirildiğinde, Otomatik Ölçekleme Etkinleştirildi, insansızın çocuk ölçek değerlerinin değişmesine yanıt olarak karakterin boyutunun değişmesine neden olur.
İnsansızın eklemlerinin Enum.HumanoidStateType.Dead durumunda kırılıp kırılmadığını belirler.
Fotoğraf makinesinin konu pozisyonuna uygulanan bir ofset, Kamera Konusu bu insansıza ayarlandığında.
Humanoit'in adının ve sağlık görüntüsünün uzaklık davranışını kontrol eder.
Kafalarının üzerinde görüntülenen bir Insanoid'in metnini ayarlar.
Şu anda durduğu Enum.Material üzerindeki Humanoid açıklar.Eğer Humanoid hiçbir şeyin üzerinde durmuyorsa, bu özelliğin değeri Hava olacaktır.
Menzildeki Humanoid'in mevcut sağlığını tanımlar [0, Humanoid.MaxHealth ].
Bir insansızın sağlık çubuğunun görülebildiği mesafeyi kontrol etmek için DisplayDistanceType özelliği ile birlikte kullanılır.
Humanoit'in sağlık çubuğunun görüntülenmesine izin verilen durumları kontrol eder.
Humanoid.RootPart yerden uzak mesafeyi belirler. yerden uzak mesafe olması gereken.
Eğer true , Humanoid yukarı doğru bir güçle atlar.
Humanoid atladığı yüksekliğe kontrol sağlar.
Zıplarken Humanoid üzerine ne kadar yukarı kuvvet uygulanacağını belirler.
Bir insansızın maksimum değeri Health .
Bir insansızın kaymadan üzerinde yürüyebileceği maksimum eğim açısı.
Humanoid'nin yürüdüğü yönü tanımlar.
Bir insansızın adının görülebildiği mesafeyi kontrol etmek için Humanoid.DisplayDistanceType özelliği ile birlikte kullanılır.
Bir insansızın adının ve sağlık çubuğunun duvarların veya diğer nesnelerin arkasında görülebileceğini kontrol eder.
Humanoid şu anda Enum.HumanoidStateType.PlatformStanding durumunda olup olmadığını belirler.
Geliştiricilerin Neck'in kaldırılması veya geçici olarak bağlantı kesilmesi durumunda bir oyuncunun ölmesini devre dışı bırakmasına izin verir.
Bu Humanoid kullanılıyor mu miras R6 karakter kolu, yoksa yeni R15 karakter kolu mı? tanımlar.
Humanoit'in HumanoidRootPart nesnesine bir referans.
Bir Humanoid şu anda oturduğu koltuğa referans, varsa.
Humanoid'nin şu anda oturup oturmadığını tanımlar.
Bir Player ile dünyada son kez tıklanan Humanoid 'i kontrol eden 3B pozisyonu tanımlar, bir Tool kullanırken.
JumpHeight (yanlış) veya Humanoid.JumpPower (doğru) özellik kullanılıp kullanılmadığını belirler.
İnsansızın maksimum hareket hızını saniye başına çivilerle tanımlar.
Bir insansız tarafından ulaşılmaya çalışılan bir parçaya referans.
Bir insansızın ulaşmaya çalıştığı pozisyon, Humanoid:MoveTo() 'ya bir çağrı yapıldıktan sonra.
Yöntemler
Belirtilen Accessory 'yi insansızın ebeveynine bağlar.
Bir insansız karakterde Motor6D bağlantıların bir ağacını bir araya getirerek Attachment nesneleri birleştirerek birleştirir.
Verilen Humanoid 'e girmek için Enum.HumanoidStateType 'i ayarlar.
Humanoid'in ebeveyninin şu anda giydiği bir dizi Accessory nesneyi döndürür.
İnsansızın önbelleğinde saklanmış HumanoidDescription kopyasını döndürür, ki bu onun mevcut görünümünü tanımlar.
Bir vücut parçasını bu yönteme geçir (vücut parçası Humanoid'in bir kardeşi ve bir Model'in çocuğu olmalıdır) ile Enum.BodyPartR15 'nin Part 'sini almak için.
Verilen Enum.Limb ile ilişkili olan Part sayısal değeri döndürür.
İnsansızın mevcut Enum.HumanoidStateType 'sini döndürür.
Bir Enum.HumanoidStateType 'nin Humanoid için etkinleştirilip etkinleştirilmediğini döndürür.
Verilen yönde yürümesine neden olur Humanoid .
Humanoid ı, Humanoid.WalkToPoint ve Humanoid.WalkToPart özelliklerini ayarlayarak verilen konuma yürümeye çalışmasına neden olur.
Humanoit'in ebeveyni tarafından giyilen tüm Accessory nesneleri kaldırır
Dinamik olarak bir Insanoid vücut parçasını farklı bir parça ile değiştirir.
Verilen Enum.HumanoidStateType 'nin Humanoid için etkinleştirilip etkinleştirilmediğini ayarlar.
Verilen Humanoid.Health tarafından korunmuyorsa, Humanoid ın değerini düşürür, eğer bir ForceField tarafından korunmazsa.
Şu anda Tool tarafından donatılan herhangi birini çıkarır Humanoid.
- ApplyDescription(humanoidDescription : HumanoidDescription,assetTypeVerification : Enum.AssetTypeVerification):()
Karakterin görünümünü HumanoidDescription geçen ile eşleştirir.
- ApplyDescriptionReset(humanoidDescription : HumanoidDescription,assetTypeVerification : Enum.AssetTypeVerification):()
Karakterin görünümünü, dış değişikliklerden sonra bile, HumanoidDescription geçen görünüme eşleştirir.
Duygular oynar ve başarılı bir şekilde çalıştırıldıysa geri döner.
Olaylar
Bir Humanoid üzerinde yükselen hız değiştiğinde ateş eder.
Humanoid öldüğünde ateş eder.
Humanoid veya FallingDown``Enum.HumanoidStateType girdiğinde yangın çıkar
Humanoid veya Freefall``Enum.HumanoidStateType girdiğinde yangın çıkar
Humanoid veya GettingUp``Enum.HumanoidStateType girdiğinde yangın çıkar
Humanoid.Health değiştiğinde veya Humanoid.MaxHealth ayarlandığında ateş eder (veya ayarlanır).
Giriş yaptığında ve Humanoid çıktığında Jumping``Enum.HumanoidStateType girer ve ayrılır.
bir hedef tarafından ilan edilen bir hedefe yürümeyi bitirdiğinde ateş eder.
Humanoid veya PlatformStanding``Enum.HumanoidStateType girdiğinde yangın çıkar
Humanoid veya Ragdoll``Enum.HumanoidStateType girdiğinde yangın çıkar
Bir Humanoid üzerinde çalışan hızda değişiklikler olduğunda ateş eder.
Bir Humanoid ya oturuyor veya kalkıyor, bir Seat ya oturuyor veya kalkıyor veya bir VehicleSeat ya oturuyor veya kalkıyor.
Humanoid durumu değiştiğinde ateş eder.
Humanoid:SetStateEnabled() 'de çağrıldığında ateş eder. Humanoid üzerinde.
Humanoid veya StrafingNoPhysics``Enum.HumanoidStateType girdiğinde yangın çıkar
Bir Humanoid ın suda yüzdüğü hız değiştiğinde ateş eder Terrain suda yüzerken.
Bir insansızın uzuvlarından biri başka biriyle temasa geçtiğinde ateş eder BasePart .
Özellikler
AutoJumpEnabled
Kod Örnekleri
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local button = script.Parent
local function update()
-- Güncelleme düğmesi metni
if player.AutoJumpEnabled then
button.Text = "Auto-Jump is ON"
else
button.Text = "Auto-Jump is OFF"
end
-- Oyuncunun karakterinde özelliği yansıt, eğer bir tane varsa
if player.Character then
local human = player.Character:FindFirstChild("Humanoid")
if human then
human.AutoJumpEnabled = player.AutoJumpEnabled
end
end
end
local function onActivated()
-- Otomatik atlama geçişi değiştir
player.AutoJumpEnabled = not player.AutoJumpEnabled
-- Diğer her şeyi güncelle
update()
end
button.Activated:Connect(onActivated)
update()
AutoRotate
Kod Örnekleri
local button = script.Parent
local enabled = true
local ON_COLOR = BrickColor.Green()
local OFF_COLOR = BrickColor.Red()
local function touchButton(humanoid)
if enabled then
enabled = false
button.BrickColor = OFF_COLOR
if humanoid.AutoRotate then
print(humanoid:GetFullName() .. " can no longer auto-rotate!")
humanoid.AutoRotate = false
else
print(humanoid:GetFullName() .. " can now auto-rotate!")
humanoid.AutoRotate = true
end
task.wait(1)
button.BrickColor = ON_COLOR
enabled = true
end
end
local function onTouched(hit)
local char = hit:FindFirstAncestorWhichIsA("Model")
if char then
local humanoid = char:FindFirstChildOfClass("Humanoid")
if humanoid then
touchButton(humanoid)
end
end
end
button.Touched:Connect(onTouched)
button.BrickColor = ON_COLOR
AutomaticScalingEnabled
BreakJointsOnDeath
CameraOffset
Kod Örnekleri
local RunService = game:GetService("RunService")
local playerModel = script.Parent
local humanoid = playerModel:WaitForChild("Humanoid")
local function updateBobbleEffect()
local now = tick()
if humanoid.MoveDirection.Magnitude > 0 then -- Is the character walking?
local velocity = humanoid.RootPart.Velocity
local bobble_X = math.cos(now * 9) / 5
local bobble_Y = math.abs(math.sin(now * 12)) / 5
local bobble = Vector3.new(bobble_X, bobble_Y, 0) * math.min(1, velocity.Magnitude / humanoid.WalkSpeed)
humanoid.CameraOffset = humanoid.CameraOffset:lerp(bobble, 0.25)
else
-- Scale down the CameraOffset so that it shifts back to its regular position.
humanoid.CameraOffset = humanoid.CameraOffset * 0.75
end
end
RunService.RenderStepped:Connect(updateBobbleEffect)
DisplayDistanceType
Kod Örnekleri
local humanoid = script.Parent
humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.Viewer
humanoid.HealthDisplayDistance = 0
humanoid.NameDisplayDistance = 100
DisplayName
EvaluateStateMachine
FloorMaterial
Health
HealthDisplayDistance
HealthDisplayType
HipHeight
Jump
JumpHeight
JumpPower
MaxHealth
MaxSlopeAngle
Kod Örnekleri
local player = game.Players.LocalPlayer
local char = player.CharacterAdded:wait()
local h = char:FindFirstChild("Humanoid")
h.MaxSlopeAngle = 30
MoveDirection
Kod Örnekleri
local RunService = game:GetService("RunService")
local playerModel = script.Parent
local humanoid = playerModel:WaitForChild("Humanoid")
local function updateBobbleEffect()
local now = tick()
if humanoid.MoveDirection.Magnitude > 0 then -- Is the character walking?
local velocity = humanoid.RootPart.Velocity
local bobble_X = math.cos(now * 9) / 5
local bobble_Y = math.abs(math.sin(now * 12)) / 5
local bobble = Vector3.new(bobble_X, bobble_Y, 0) * math.min(1, velocity.Magnitude / humanoid.WalkSpeed)
humanoid.CameraOffset = humanoid.CameraOffset:lerp(bobble, 0.25)
else
-- Scale down the CameraOffset so that it shifts back to its regular position.
humanoid.CameraOffset = humanoid.CameraOffset * 0.75
end
end
RunService.RenderStepped:Connect(updateBobbleEffect)
NameDisplayDistance
NameOcclusion
Kod Örnekleri
local Players = game:GetService("Players")
local function onCharacterAdded(character)
local humanoid = character:WaitForChild("Humanoid")
humanoid.NamOcclusion = Enum.NameOcclusion.OccludeAll
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)
PlatformStand
RequiresNeck
RigType
RootPart
SeatPart
Sit
TargetPoint
UseJumpPower
WalkSpeed
WalkToPart
WalkToPoint
Kod Örnekleri
local function moveTo(humanoid, targetPoint, andThen)
local targetReached = false
-- listen for the humanoid reaching its target
local connection
connection = humanoid.MoveToFinished:Connect(function(reached)
targetReached = true
connection:Disconnect()
connection = nil
if andThen then
andThen(reached)
end
end)
-- start walking
humanoid:MoveTo(targetPoint)
-- execute on a new thread so as to not yield function
task.spawn(function()
while not targetReached do
-- does the humanoid still exist?
if not (humanoid and humanoid.Parent) then
break
end
-- has the target changed?
if humanoid.WalkToPoint ~= targetPoint then
break
end
-- refresh the timeout
humanoid:MoveTo(targetPoint)
task.wait(6)
end
-- disconnect the connection if it is still connected
if connection then
connection:Disconnect()
connection = nil
end
end)
end
local function andThen(reached)
print((reached and "Destination reached!") or "Failed to reach destination!")
end
moveTo(script.Parent:WaitForChild("Humanoid"), Vector3.new(50, 0, 50), andThen)
Yöntemler
AddAccessory
Parametreler
Dönüşler
Kod Örnekleri
local playerModel = script.Parent
local humanoid = playerModel:WaitForChild("Humanoid")
local clockworksShades = Instance.new("Accessory")
clockworksShades.Name = "ClockworksShades"
local handle = Instance.new("Part")
handle.Name = "Handle"
handle.Size = Vector3.new(1, 1.6, 1)
handle.Parent = clockworksShades
local faceFrontAttachment = Instance.new("Attachment")
faceFrontAttachment.Name = "FaceFrontAttachment"
faceFrontAttachment.Position = Vector3.new(0, -0.24, -0.45)
faceFrontAttachment.Parent = handle
local mesh = Instance.new("SpecialMesh")
mesh.Name = "Mesh"
mesh.Scale = Vector3.new(1, 1.3, 1)
mesh.MeshId = "rbxassetid://1577360"
mesh.TextureId = "rbxassetid://1577349"
mesh.Parent = handle
humanoid:AddAccessory(clockworksShades)
BuildRigFromAttachments
Dönüşler
Kod Örnekleri
local function createJoint(jointName, att0, att1)
local part0, part1 = att0.Parent, att1.Parent
local newMotor = part1:FindFirstChild(jointName)
if not (newMotor and newMotor:IsA("Motor6D")) then
newMotor = Instance.new("Motor6D")
end
newMotor.Name = jointName
newMotor.Part0 = part0
newMotor.Part1 = part1
newMotor.C0 = att0.CFrame
newMotor.C1 = att1.CFrame
newMotor.Parent = part1
end
local function buildJointsFromAttachments(part, characterParts)
if not part then
return
end
-- first, loop thru all of the part's children to find attachments
for _, attachment in pairs(part:GetChildren()) do
if attachment:IsA("Attachment") then
-- only do joint build from "RigAttachments"
local attachmentName = attachment.Name
local findPos = attachmentName:find("RigAttachment")
if findPos then
-- also don't make double joints (there is the same named
-- rigattachment under two parts)
local jointName = attachmentName:sub(1, findPos - 1)
if not part:FindFirstChild(jointName) then
-- try to find other part with same rig attachment name
for _, characterPart in pairs(characterParts) do
if part ~= characterPart then
local matchingAttachment = characterPart:FindFirstChild(attachmentName)
if matchingAttachment and matchingAttachment:IsA("Attachment") then
createJoint(jointName, attachment, matchingAttachment)
buildJointsFromAttachments(characterPart, characterParts)
break
end
end
end
end
end
end
end
end
local function buildRigFromAttachments(humanoid)
local rootPart = humanoid.RootPart
assert(rootPart, "Humanoid has no HumanoidRootPart.")
local characterParts = {}
for _, descendant in ipairs(humanoid.Parent:GetDescendants()) do
if descendant:IsA("BasePart") then
table.insert(characterParts, descendant)
end
end
buildJointsFromAttachments(rootPart, characterParts)
end
local humanoid = script.Parent:WaitForChild("Humanoid")
buildRigFromAttachments(humanoid)
local AssetService = game:GetService("AssetService")
local InsertService = game:GetService("InsertService")
local MarketplaceService = game:GetService("MarketplaceService")
local PACKAGE_ASSET_ID = 193700907 -- Circuit Breaker
local function addAttachment(part, name, position, orientation)
local attachment = Instance.new("Attachment")
attachment.Name = name
attachment.Parent = part
if position then
attachment.Position = position
end
if orientation then
attachment.Orientation = orientation
end
return attachment
end
local function createBaseCharacter()
local character = Instance.new("Model")
local humanoid = Instance.new("Humanoid")
humanoid.Parent = character
local rootPart = Instance.new("Part")
rootPart.Name = "HumanoidRootPart"
rootPart.Size = Vector3.new(2, 2, 1)
rootPart.Transparency = 1
rootPart.Parent = character
addAttachment(rootPart, "RootRigAttachment")
local head = Instance.new("Part")
head.Name = "Head"
head.Size = Vector3.new(2, 1, 1)
head.Parent = character
local headMesh = Instance.new("SpecialMesh")
headMesh.Scale = Vector3.new(1.25, 1.25, 1.25)
headMesh.MeshType = Enum.MeshType.Head
headMesh.Parent = head
local face = Instance.new("Decal")
face.Name = "face"
face.Texture = "rbxasset://textures/face.png"
face.Parent = head
addAttachment(head, "FaceCenterAttachment")
addAttachment(head, "FaceFrontAttachment", Vector3.new(0, 0, -0.6))
addAttachment(head, "HairAttachment", Vector3.new(0, 0.6, 0))
addAttachment(head, "HatAttachment", Vector3.new(0, 0.6, 0))
addAttachment(head, "NeckRigAttachment", Vector3.new(0, -0.5, 0))
return character, humanoid
end
local function createR15Package(packageAssetId)
local packageAssetInfo = MarketplaceService:GetProductInfo(packageAssetId)
local character, humanoid = createBaseCharacter()
character.Name = packageAssetInfo.Name
local assetIds = AssetService:GetAssetIdsForPackage(packageAssetId)
for _, assetId in pairs(assetIds) do
local limb = InsertService:LoadAsset(assetId)
local r15 = limb:FindFirstChild("R15")
if r15 then
for _, part in pairs(r15:GetChildren()) do
part.Parent = character
end
else
for _, child in pairs(limb:GetChildren()) do
child.Parent = character
end
end
end
humanoid:BuildRigFromAttachments()
return character
end
local r15Package = createR15Package(PACKAGE_ASSET_ID)
r15Package.Parent = workspace
ChangeState
Parametreler
Dönüşler
Kod Örnekleri
local UserInputService = game:GetService("UserInputService")
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local doubleJumpEnabled = false
humanoid.StateChanged:Connect(function(_oldState, newState)
if newState == Enum.HumanoidStateType.Jumping then
if not doubleJumpEnabled then
task.wait(0.2)
if humanoid:GetState() == Enum.HumanoidStateType.Freefall then
doubleJumpEnabled = true
end
end
elseif newState == Enum.HumanoidStateType.Landed then
doubleJumpEnabled = false
end
end)
UserInputService.InputBegan:Connect(function(inputObject)
if inputObject.KeyCode == Enum.KeyCode.Space then
if doubleJumpEnabled then
if humanoid:GetState() ~= Enum.HumanoidStateType.Jumping then
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
task.spawn(function()
doubleJumpEnabled = false
end)
end
end
end
end)
GetAccessories
Dönüşler
Kod Örnekleri
local Players = game:GetService("Players")
local function onPlayerAddedAsync(player)
local connection = player.CharacterAppearanceLoaded:Connect(function(character)
-- Tüm aksesuarlar bu noktada yüklendi
local humanoid = character:FindFirstChildOfClass("Humanoid")
local numAccessories = #humanoid:GetAccessories()
print(("Destroying %d accessories for %s"):format(numAccessories, player.Name))
humanoid:RemoveAccessories()
end)
-- Oyuncudan ayrıldıktan sonra bağlantımızı kesmediğimizden emin olun
-- oyuncunun toplanan çöp almasına izin vermek
player.AncestryChanged:Wait()
connection:Disconnect()
end
for _, player in Players:GetPlayers() do
task.spawn(onPlayerAddedAsync, player)
end
Players.PlayerAdded:Connect(onPlayerAddedAsync)
GetBodyPartR15
Parametreler
Dönüşler
GetLimb
Parametreler
Dönüşler
Kod Örnekleri
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
for _, child in pairs(character:GetChildren()) do
local limb = humanoid:GetLimb(child)
if limb ~= Enum.Limb.Unknown then
print(child.Name .. " is part of limb " .. limb.Name)
end
end
GetState
Dönüşler
Kod Örnekleri
local UserInputService = game:GetService("UserInputService")
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local doubleJumpEnabled = false
humanoid.StateChanged:Connect(function(_oldState, newState)
if newState == Enum.HumanoidStateType.Jumping then
if not doubleJumpEnabled then
task.wait(0.2)
if humanoid:GetState() == Enum.HumanoidStateType.Freefall then
doubleJumpEnabled = true
end
end
elseif newState == Enum.HumanoidStateType.Landed then
doubleJumpEnabled = false
end
end)
UserInputService.InputBegan:Connect(function(inputObject)
if inputObject.KeyCode == Enum.KeyCode.Space then
if doubleJumpEnabled then
if humanoid:GetState() ~= Enum.HumanoidStateType.Jumping then
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
task.spawn(function()
doubleJumpEnabled = false
end)
end
end
end
end)
GetStateEnabled
Parametreler
Dönüşler
Kod Örnekleri
local humanoid = script.Parent:WaitForChild("Humanoid")
-- Set state
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
-- Get state
print(humanoid:GetStateEnabled(Enum.HumanoidStateType.Jumping)) -- false
Move
Parametreler
Dönüşler
Kod Örnekleri
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
RunService:BindToRenderStep("move", Enum.RenderPriority.Character.Value + 1, function()
if player.Character then
local humanoid = player.Character:FindFirstChild("Humanoid")
if humanoid then
humanoid:Move(Vector3.new(0, 0, -1), true)
end
end
end)
MoveTo
Parametreler
Dönüşler
Kod Örnekleri
local function moveTo(humanoid, targetPoint, andThen)
local targetReached = false
-- listen for the humanoid reaching its target
local connection
connection = humanoid.MoveToFinished:Connect(function(reached)
targetReached = true
connection:Disconnect()
connection = nil
if andThen then
andThen(reached)
end
end)
-- start walking
humanoid:MoveTo(targetPoint)
-- execute on a new thread so as to not yield function
task.spawn(function()
while not targetReached do
-- does the humanoid still exist?
if not (humanoid and humanoid.Parent) then
break
end
-- has the target changed?
if humanoid.WalkToPoint ~= targetPoint then
break
end
-- refresh the timeout
humanoid:MoveTo(targetPoint)
task.wait(6)
end
-- disconnect the connection if it is still connected
if connection then
connection:Disconnect()
connection = nil
end
end)
end
local function andThen(reached)
print((reached and "Destination reached!") or "Failed to reach destination!")
end
moveTo(script.Parent:WaitForChild("Humanoid"), Vector3.new(50, 0, 50), andThen)
RemoveAccessories
Dönüşler
Kod Örnekleri
local Players = game:GetService("Players")
local function onPlayerAddedAsync(player)
local connection = player.CharacterAppearanceLoaded:Connect(function(character)
-- Tüm aksesuarlar bu noktada yüklendi
local humanoid = character:FindFirstChildOfClass("Humanoid")
local numAccessories = #humanoid:GetAccessories()
print(("Destroying %d accessories for %s"):format(numAccessories, player.Name))
humanoid:RemoveAccessories()
end)
-- Oyuncudan ayrıldıktan sonra bağlantımızı kesmediğimizden emin olun
-- oyuncunun toplanan çöp almasına izin vermek
player.AncestryChanged:Wait()
connection:Disconnect()
end
for _, player in Players:GetPlayers() do
task.spawn(onPlayerAddedAsync, player)
end
Players.PlayerAdded:Connect(onPlayerAddedAsync)
ReplaceBodyPartR15
Parametreler
Dönüşler
SetStateEnabled
Parametreler
Dönüşler
Kod Örnekleri
local character = script.Parent
local JUMP_DEBOUNCE = 1
local humanoid = character:WaitForChild("Humanoid")
local isJumping = false
humanoid.StateChanged:Connect(function(_oldState, newState)
if newState == Enum.HumanoidStateType.Jumping then
if not isJumping then
isJumping = true
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
end
elseif newState == Enum.HumanoidStateType.Landed then
if isJumping then
isJumping = false
task.wait(JUMP_DEBOUNCE)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
end
end
end)
TakeDamage
Parametreler
Dönüşler
Kod Örnekleri
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
humanoid:TakeDamage(99)
UnequipTools
Dönüşler
ApplyDescription
Parametreler
Dönüşler
ApplyDescriptionReset
Parametreler
Dönüşler
Olaylar
Climbing
Parametreler
Kod Örnekleri
local Players = game:GetService("Players")
local function onCharacterClimbing(character, speed)
print(character.Name, "is climbing at a speed of", speed, "studs / second.")
end
local function onCharacterAdded(character)
character.Humanoid.Climbing:Connect(function(speed)
onCharacterClimbing(character, speed)
end)
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)
Died
Kod Örnekleri
local Players = game:GetService("Players")
local function onPlayerAdded(player)
local function onCharacterAdded(character)
local humanoid = character:WaitForChild("Humanoid")
local function onDied()
print(player.Name, "has died!")
end
humanoid.Died:Connect(onDied)
end
player.CharacterAdded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)
HealthChanged
Parametreler
Kod Örnekleri
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local function onCharacterAdded(character)
local humanoid = character:WaitForChild("Humanoid")
local currentHealth = humanoid.Health
local function onHealthChanged(health)
local change = math.abs(currentHealth - health)
print("The humanoid's health", (currentHealth > health and "decreased by" or "increased by"), change)
currentHealth = health
end
humanoid.HealthChanged:Connect(onHealthChanged)
end
player.CharacterAdded:Connect(onCharacterAdded)
local Players = game:GetService("Players")
local player = Players.LocalPlayer
-- Paste script into a LocalScript that is
-- parented to a Frame within a Frame
local frame = script.Parent
local container = frame.Parent
container.BackgroundColor3 = Color3.new(0, 0, 0) -- black
-- This function is called when the humanoid's health changes
local function onHealthChanged()
local human = player.Character.Humanoid
local percent = human.Health / human.MaxHealth
-- Change the size of the inner bar
frame.Size = UDim2.new(percent, 0, 1, 0)
-- Change the color of the health bar
if percent < 0.1 then
frame.BackgroundColor3 = Color3.new(1, 0, 0) -- black
elseif percent < 0.4 then
frame.BackgroundColor3 = Color3.new(1, 1, 0) -- yellow
else
frame.BackgroundColor3 = Color3.new(0, 1, 0) -- green
end
end
-- This function runs is called the player spawns in
local function onCharacterAdded(character)
local human = character:WaitForChild("Humanoid")
-- Pattern: update once now, then any time the health changes
human.HealthChanged:Connect(onHealthChanged)
onHealthChanged()
end
-- Connect our spawn listener; call it if already spawned
player.CharacterAdded:Connect(onCharacterAdded)
if player.Character then
onCharacterAdded(player.Character)
end
MoveToFinished
Parametreler
Kod Örnekleri
local function moveTo(humanoid, targetPoint, andThen)
local targetReached = false
-- listen for the humanoid reaching its target
local connection
connection = humanoid.MoveToFinished:Connect(function(reached)
targetReached = true
connection:Disconnect()
connection = nil
if andThen then
andThen(reached)
end
end)
-- start walking
humanoid:MoveTo(targetPoint)
-- execute on a new thread so as to not yield function
task.spawn(function()
while not targetReached do
-- does the humanoid still exist?
if not (humanoid and humanoid.Parent) then
break
end
-- has the target changed?
if humanoid.WalkToPoint ~= targetPoint then
break
end
-- refresh the timeout
humanoid:MoveTo(targetPoint)
task.wait(6)
end
-- disconnect the connection if it is still connected
if connection then
connection:Disconnect()
connection = nil
end
end)
end
local function andThen(reached)
print((reached and "Destination reached!") or "Failed to reach destination!")
end
moveTo(script.Parent:WaitForChild("Humanoid"), Vector3.new(50, 0, 50), andThen)
Running
Parametreler
Kod Örnekleri
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
local character = localPlayer.Character or localPlayer.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local function onRunning(speed: number)
if speed > 0 then
print(`{localPlayer.Name} is running`)
else
print(`{localPlayer.Name} has stopped`)
end
end
humanoid.Running:Connect(function(speed: number)
onRunning(speed)
end)
Seated
Parametreler
Kod Örnekleri
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local function onSeated(isSeated, seat)
if isSeated then
print("I'm now sitting on: " .. seat.Name .. "!")
else
print("I'm not sitting on anything")
end
end
humanoid.Seated:Connect(onSeated)
StateChanged
Parametreler
Kod Örnekleri
local character = script.Parent
local primaryPart = character.PrimaryPart
-- partiküller oluştur create particles
local particles = Instance.new("ParticleEmitter")
particles.Size = NumberSequence.new(1)
particles.Transparency = NumberSequence.new(0, 1)
particles.Acceleration = Vector3.new(0, -10, 0)
particles.Lifetime = NumberRange.new(1)
particles.Rate = 20
particles.EmissionDirection = Enum.NormalId.Back
particles.Enabled = false
particles.Parent = primaryPart
local humanoid = character:WaitForChild("Humanoid")
local isJumping = false
-- insansız durumu dinle
local function onStateChanged(_oldState, newState)
if newState == Enum.HumanoidStateType.Jumping then
if not isJumping then
isJumping = true
particles.Enabled = true
end
elseif newState == Enum.HumanoidStateType.Landed then
if isJumping then
isJumping = false
particles.Enabled = false
end
end
end
humanoid.StateChanged:Connect(onStateChanged)
local character = script.Parent
local JUMP_DEBOUNCE = 1
local humanoid = character:WaitForChild("Humanoid")
local isJumping = false
humanoid.StateChanged:Connect(function(_oldState, newState)
if newState == Enum.HumanoidStateType.Jumping then
if not isJumping then
isJumping = true
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
end
elseif newState == Enum.HumanoidStateType.Landed then
if isJumping then
isJumping = false
task.wait(JUMP_DEBOUNCE)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
end
end
end)
StateEnabledChanged
Parametreler
Kod Örnekleri
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local function onStateEnabledChanged(state, enabled)
if enabled then
print(state.Name .. " has been enabled")
else
print(state.Name .. " has been disabled")
end
end
humanoid.StateEnabledChanged:Connect(onStateEnabledChanged)
Touched
Parametreler
Kod Örnekleri
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local partInfo = {}
local debounce = false
local function onHumanoidTouched(hit, _limb)
if debounce then
return
end
if not hit.CanCollide or hit.Transparency ~= 0 then
return
end
if not partInfo[hit] then
partInfo[hit] = {
BrickColor = hit.BrickColor,
Material = hit.Material,
}
hit.BrickColor = BrickColor.new("Gold")
hit.Material = Enum.Material.Ice
debounce = true
task.wait(0.2)
debounce = false
end
end
local touchedConnection = humanoid.Touched:Connect(onHumanoidTouched)
local function onHumanoidDied()
if touchedConnection then
touchedConnection:Disconnect()
end
-- undo all of the gold
for part, info in pairs(partInfo) do
if part and part.Parent then
part.BrickColor = info.BrickColor
part.Material = info.Material
end
end
end
humanoid.Died:Connect(onHumanoidDied)