Sungmingamerpro13

Controles estilo Super Mario bros de Nes

Aug 31st, 2026
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 3.31 KB | None | 0 0
  1. local player = game.Players.LocalPlayer
  2. local Character = player.Character or player.CharacterAdded:Wait()
  3. local Humanoid = Character:WaitForChild("Humanoid")
  4. local RunService = game:GetService("RunService")
  5. local ContextActionService = game:GetService("ContextActionService")
  6. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  7.  
  8. local jumping = false
  9. local leftValue, rightValue = 0, 0
  10. local WALK_SPEED = 16
  11. local RUN_SPEED = 24
  12. local FireFlower = player:WaitForChild("HasFireFlower")
  13. local FireballEvent = ReplicatedStorage:WaitForChild("FireballEvent")
  14.  
  15. local function onZ(actionName, inputState, inputObject)
  16.     local Character = player.Character
  17.     if not Character then
  18.         return Enum.ContextActionResult.Pass
  19.     end
  20.  
  21.     local Humanoid = Character:FindFirstChildOfClass("Humanoid")
  22.     if not Humanoid then
  23.         return Enum.ContextActionResult.Pass
  24.     end
  25.  
  26.     -- 🏃 Si NO tiene Flor de Fuego, Z corre
  27.     if inputState == Enum.UserInputState.Begin then
  28.         print("🏃 CORRER")
  29.  
  30.         Humanoid.WalkSpeed = 24
  31.  
  32.     elseif inputState == Enum.UserInputState.End then
  33.         print("🚶 VELOCIDAD NORMAL")
  34.  
  35.         Humanoid.WalkSpeed = 16
  36.     end
  37.  
  38.     return Enum.ContextActionResult.Sink
  39. end
  40.  
  41. local function onLeft(actionName, inputState)
  42.     if inputState == Enum.UserInputState.Begin then
  43.         leftValue = 1
  44.     elseif inputState == Enum.UserInputState.End then
  45.         leftValue = 0
  46.     end
  47. end
  48.  
  49. local function onRight(actionName, inputState)
  50.     if inputState == Enum.UserInputState.Begin then
  51.         rightValue = 1
  52.     elseif inputState == Enum.UserInputState.End then
  53.         rightValue = 0
  54.     end
  55. end
  56.  
  57. local function onJump(actionName, inputState)
  58.     if inputState == Enum.UserInputState.Begin then
  59.         jumping = true
  60.     elseif inputState == Enum.UserInputState.End then
  61.         jumping = false
  62.     end
  63. end
  64.  
  65. local function onUpdate()
  66.     if player.Character and player.Character:FindFirstChild("Humanoid") then
  67.         if jumping then
  68.             player.Character.Humanoid.Jump = true
  69.         end
  70.         local moveDirection = rightValue - leftValue
  71.         player.Character.Humanoid:Move(Vector3.new(moveDirection,0,0), false)
  72.     end
  73. end
  74.  
  75. local function onFire(actionName, inputState, inputObject)
  76.     if inputState ~= Enum.UserInputState.Begin then
  77.         return Enum.ContextActionResult.Pass
  78.     end
  79.  
  80.     local Character = player.Character
  81.     if not Character then
  82.         return Enum.ContextActionResult.Pass
  83.     end
  84.  
  85.     -- Comprobar que tiene el poder de fuego
  86.     if Character:GetAttribute("CanShootFire") ~= true then
  87.         return Enum.ContextActionResult.Pass
  88.     end
  89.  
  90.     -- Comprobar que la FireFlower está equipada en la mano
  91.     local FireFlower = Character:FindFirstChild("fireBall")
  92.  
  93.     if not FireFlower then
  94.         return Enum.ContextActionResult.Pass
  95.     end
  96.  
  97.     -- 🔥 DISPARAR
  98.     FireballEvent:FireServer()
  99.  
  100.     return Enum.ContextActionResult.Sink
  101. end
  102.  
  103. RunService:BindToRenderStep("Control", Enum.RenderPriority.Input.Value, onUpdate)
  104.  
  105.  
  106. ContextActionService:BindAction("Left", onLeft, true, "Q", Enum.KeyCode.A, Enum.KeyCode.Left, Enum.KeyCode.DPadLeft, Enum.KeyCode.ButtonL1)
  107. ContextActionService:BindAction("Right", onRight, true, "E", Enum.KeyCode.D, Enum.KeyCode.Right, Enum.KeyCode.DPadRight, Enum.KeyCode.ButtonR1)
  108. ContextActionService:BindAction("Run", onZ, true, Enum.KeyCode.Z)
  109. ContextActionService:BindAction("Jump", onJump, true, Enum.KeyCode.X)
  110. ContextActionService:BindAction("Fire", onFire, false, Enum.KeyCode.C)
  111.  
Advertisement
Add Comment
Please, Sign In to add comment