Advertisement
Anukun_Lucifer

FirstPersonCam

Oct 19th, 2024
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.36 KB | Gaming | 0 0
  1. local player = game.Players.LocalPlayer
  2.  
  3. local character = player.Character or player.CharacterAdded:Wait()
  4. local humanoid = character:WaitForChild("Humanoid")
  5. local camera = workspace.CurrentCamera
  6. local mouse = player:GetMouse()
  7. local parts = {"RightUpperArm", "RightLowerArm", "RightHand", "LeftUpperArm", "LeftLowerArm", "LeftHand",
  8.     "RightUpperLeg", "RightLowerLeg", "RightFoot", "LeftUpperLeg", "LeftLowerLeg", "LeftFoot",
  9.     "UpperTorso", "LowerTorso"}
  10.  
  11. -- เปลี่ยนรูปเคอร์เซอร์
  12. local function changeCursorIcon()
  13.     mouse.Icon = "rbxassetid://5054846840" -- Asset ID ของเคอร์เซอร์
  14. end
  15.  
  16. -- อัปเดตตัวละครและจัดการความโปร่งใส
  17. local function updateCharacter(newCharacter)
  18.     character = newCharacter or player.Character
  19.     humanoid = character:WaitForChild("Humanoid")
  20.     local cachedParts = {} -- เก็บชิ้นส่วนของตัวละคร
  21.  
  22.     -- วนลูปเก็บชิ้นส่วนที่พบใน character
  23.     for _, partName in ipairs(parts) do
  24.         local part = character:FindFirstChild(partName)
  25.         if part then table.insert(cachedParts, part) end
  26.     end
  27.  
  28.     -- อัปเดตค่าความโปร่งใสของชิ้นส่วนในทุกเฟรม
  29.     game:GetService("RunService").RenderStepped:Connect(function()
  30.         for _, part in ipairs(cachedParts) do
  31.             part.LocalTransparencyModifier = 0 -- ตั้งค่าความโปร่งใส
  32.         end
  33.         humanoid.CameraOffset = Vector3.new(0, 0, -1) -- ปรับมุมมองกล้อง
  34.     end)
  35. end
  36.  
  37. -- ล็อคมุมกล้องเป็น FirstPerson
  38. local function lockFirstPerson()
  39.     player.CameraMode = Enum.CameraMode.LockFirstPerson
  40.     camera.CameraSubject = humanoid -- ติดตาม humanoid
  41. end
  42.  
  43. -- การตั้งค่าเริ่มต้นเมื่อเกมเริ่ม
  44. local function initializeGame()
  45.     updateCharacter(character)
  46.     lockFirstPerson()
  47.     changeCursorIcon()
  48. end
  49.  
  50. -- เรียกใช้งานเมื่อเริ่มเกม
  51. initializeGame()
  52.  
  53. -- อัปเดตตัวละครเมื่อเกิดใหม่
  54. player.CharacterAdded:Connect(function(newCharacter)
  55.     updateCharacter(newCharacter)
  56.     lockFirstPerson()
  57. end)
  58.  
Tags: Roblox
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement