I am working on something and I know how to script simple ones and scripted a script you can slide for few seconds but a problem comes when I tried to make it usable for mobile players and it failed but how can I make it usable?
Code here to make it solve easier:
local UIS = game:GetService("UserInputService") local Character = script.Parent local Animation = Instance.new("Animation") Animation.AnimationId = "rbxassetid://9331454676" -- This animation is not usable, skip that local KeyBind = Enum.KeyCode.LeftControl local WouldThisPlayerSlide = true local Context = game:GetService("ContextActionService") local function onSlide(input, sildeEvent) if sildeEvent then return end if not WouldThisPlayerSlide then return end if input.KeyCode == KeyBind then WouldThisPlayerSlide = false local PlayerAnim = Character:WaitForChild("Humanoid"):LoadAnimation(Animation) PlayerAnim:Play() local Silde = Instance.new("BodyVelocity") Silde.MaxForce = Vector3.new(1,0,1) * 30000 Silde.Velocity = Character.HumanoidRootPart.CFrame.lookVector * 100 Silde.Parent = Character.HumanoidRootPart for count = 1,8 do wait(0.1) Silde.Velocity *= 0.7 end PlayerAnim:Stop() Silde:Destroy() wait(5) WouldThisPlayerSlide = true end end UIS.InputEnded:Connect(onSlide) Context:BindAction("Slide", onSlide, true, KeyBind) -- This is problem here, officer. Context:SetPosition("Slide", UDim2.new(1, -70, 0, 50)) Context:SetTitle("Slide", "Slide")
Goddamnit! I am so dumb! You had to separate them to order to work and give them a different functions before make it same as PC like this:
local AnimIds = 9333494306 local Context = game:GetService("ContextActionService") local UIS = game:GetService("UserInputService") local Character = script.Parent local Animation = Instance.new("Animation") Animation.Name = "MobileAnimTest" Animation.AnimationId = "rbxassetid://"..AnimIds local KeyBind = Enum.KeyCode.LeftControl local WouldThisPlayerSlide = true local ActionText2 = "Slide" local function onSlide() WouldThisPlayerSlide = false local PlayerAnim = Character:WaitForChild("Humanoid"):LoadAnimation(Animation) PlayerAnim:Play() local Silde = Instance.new("BodyVelocity") Silde.MaxForce = Vector3.new(1,0,1) * 30000 Silde.Velocity = Character.HumanoidRootPart.CFrame.lookVector * 100 Silde.Parent = Character.HumanoidRootPart for count = 1,8 do wait(0.1) Silde.Velocity *= 0.7 end PlayerAnim:Stop() Silde:Destroy() WouldThisPlayerSlide = true end Context:BindAction(ActionText2, onSlide, true) Context:SetPosition(ActionText2, UDim2.new(1, -70, 0, 50)) Context:SetTitle(ActionText2, "Slide")