Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game.Players.LocalPlayer
- local Character = player.Character or player.CharacterAdded:Wait()
- local Humanoid = Character:WaitForChild("Humanoid")
- local RunService = game:GetService("RunService")
- local ContextActionService = game:GetService("ContextActionService")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local jumping = false
- local leftValue, rightValue = 0, 0
- local WALK_SPEED = 16
- local RUN_SPEED = 24
- local FireFlower = player:WaitForChild("HasFireFlower")
- local FireballEvent = ReplicatedStorage:WaitForChild("FireballEvent")
- local function onZ(actionName, inputState, inputObject)
- local Character = player.Character
- if not Character then
- return Enum.ContextActionResult.Pass
- end
- local Humanoid = Character:FindFirstChildOfClass("Humanoid")
- if not Humanoid then
- return Enum.ContextActionResult.Pass
- end
- -- 🏃 Si NO tiene Flor de Fuego, Z corre
- if inputState == Enum.UserInputState.Begin then
- print("🏃 CORRER")
- Humanoid.WalkSpeed = 24
- elseif inputState == Enum.UserInputState.End then
- print("🚶 VELOCIDAD NORMAL")
- Humanoid.WalkSpeed = 16
- end
- return Enum.ContextActionResult.Sink
- end
- local function onLeft(actionName, inputState)
- if inputState == Enum.UserInputState.Begin then
- leftValue = 1
- elseif inputState == Enum.UserInputState.End then
- leftValue = 0
- end
- end
- local function onRight(actionName, inputState)
- if inputState == Enum.UserInputState.Begin then
- rightValue = 1
- elseif inputState == Enum.UserInputState.End then
- rightValue = 0
- end
- end
- local function onJump(actionName, inputState)
- if inputState == Enum.UserInputState.Begin then
- jumping = true
- elseif inputState == Enum.UserInputState.End then
- jumping = false
- end
- end
- local function onUpdate()
- if player.Character and player.Character:FindFirstChild("Humanoid") then
- if jumping then
- player.Character.Humanoid.Jump = true
- end
- local moveDirection = rightValue - leftValue
- player.Character.Humanoid:Move(Vector3.new(moveDirection,0,0), false)
- end
- end
- local function onFire(actionName, inputState, inputObject)
- if inputState ~= Enum.UserInputState.Begin then
- return Enum.ContextActionResult.Pass
- end
- local Character = player.Character
- if not Character then
- return Enum.ContextActionResult.Pass
- end
- -- Comprobar que tiene el poder de fuego
- if Character:GetAttribute("CanShootFire") ~= true then
- return Enum.ContextActionResult.Pass
- end
- -- Comprobar que la FireFlower está equipada en la mano
- local FireFlower = Character:FindFirstChild("fireBall")
- if not FireFlower then
- return Enum.ContextActionResult.Pass
- end
- -- 🔥 DISPARAR
- FireballEvent:FireServer()
- return Enum.ContextActionResult.Sink
- end
- RunService:BindToRenderStep("Control", Enum.RenderPriority.Input.Value, onUpdate)
- ContextActionService:BindAction("Left", onLeft, true, "Q", Enum.KeyCode.A, Enum.KeyCode.Left, Enum.KeyCode.DPadLeft, Enum.KeyCode.ButtonL1)
- ContextActionService:BindAction("Right", onRight, true, "E", Enum.KeyCode.D, Enum.KeyCode.Right, Enum.KeyCode.DPadRight, Enum.KeyCode.ButtonR1)
- ContextActionService:BindAction("Run", onZ, true, Enum.KeyCode.Z)
- ContextActionService:BindAction("Jump", onJump, true, Enum.KeyCode.X)
- ContextActionService:BindAction("Fire", onFire, false, Enum.KeyCode.C)
Advertisement
Add Comment
Please, Sign In to add comment