I got help making a script where when a keybind is held, a beam is fired but im having trouble implemting it into mobile
local plr = game.Players.LocalPlayer
repeat wait() until plr.Character
local c = plr.Character
local mouse = plr:GetMouse()
local func = game:GetService("ReplicatedStorage").Remotes.KameFunc
local rs = game:GetService("RunService")
local uis = game:GetService("UserInputService")
local ts = game:GetService("TweenService")
local char = plr.Character or plr.CharacterAdded:Wait()
local hrp = char:WaitForChild("HumanoidRootPart")
local hum = char:WaitForChild("Humanoid")
local animator = hum:WaitForChild("Animator")
local kamehamecharge = game:GetService("ReplicatedStorage").Animations.KamehamehaCharge
local kamehamefire = game:GetService("ReplicatedStorage").Animations.KamehamehaFire
local chargetrack = animator:LoadAnimation(kamehamecharge)
local firetrack = animator:LoadAnimation(kamehamefire)
local remotes = game:GetService("ReplicatedStorage"):FindFirstChild("Remotes")
local playergui = plr:FindFirstChild("PlayerGui")
local mobilebuttons = playergui:WaitForChild("Buttons")
local deleteab = remotes:FindFirstChild("DeleteAbility")
local hrp, hum = c:WaitForChild("HumanoidRootPart"), c:WaitForChild("Humanoid")
local Holding = false
local Dead = Enum.HumanoidStateType.Dead
local function FaceMouse()
local bp = Instance.new("BodyPosition")
bp.MaxForce = Vector3.new(900000, 900000, 900000)
bp.P = 7000
bp.D = 500
bp.Position = hrp.Position
bp.Parent = hrp
local bg = Instance.new("BodyGyro")
bg.MaxTorque = Vector3.new(math.huge,math.huge,math.huge)
bg.P = 9000
bg.D = 500
bg.CFrame = CFrame.new(hrp.Position, CFrame.new(mouse.hit.Position.X, hrp.Position.Y, mouse.hit.Position.Z).Position)
bg.Parent = hrp
return bp, bg
end
local function IgnoreList()
local IG = {workspace.FX}
for i,v in pairs(game.Players:GetChildren()) do pcall(function()
table.insert(IG, v.Character)
end)
end
return IG
end
local function ButtonDown(input, typing)
if typing or hum:GetState() == Dead then return end
if input.KeyCode == Enum.KeyCode[script:GetAttribute("KeyCode")] and script:GetAttribute("CanAttack") then
script:SetAttribute("CanAttack", false)
Holding = true
chargetrack.Looped = true
local bp, bg = FaceMouse()
local k = func:InvokeServer("Charge")
local cur = tick()
repeat
bg.CFrame = CFrame.new(hrp.Position, CFrame.new(mouse.hit.Position.X, hrp.Position.Y, mouse.hit.Position.Z).Position)
rs.Heartbeat:Wait()
until not Holding or (tick() - cur) >= 5
local p1, p2 = hrp.Position, CFrame.new(hrp.Position, mouse.hit.Position).lookVector * 25000
local r = Ray.new(p1, p2)
local IG = IgnoreList()
local part, hit = workspace:FindPartOnRayWithIgnoreList(r, IG)
if not hit or hit and (p1 - hit).Magnitude > script:GetAttribute("Range") then
hit = CFrame.new(p1, p2) * CFrame.new(0,0,-script:GetAttribute("Range")).Position
end
func:InvokeServer("Fire", p1, hit, part, k)
bp:Destroy()
bg:Destroy()
wait(script:GetAttribute("Cooldown"))
script:SetAttribute("CanAttack", true)
end
end
local function ButtonUp(input)
if hum:GetState() == Dead then return end
if input.KeyCode == Enum.KeyCode[script:GetAttribute("KeyCode")] and Holding then
Holding = false
end
end
local function Shockwave(item)
local ray = Ray.new(item:WaitForChild("In").Position + Vector3.new(0,4,0), Vector3.new(0,-10,0))
local ig = IgnoreList()
local part, hit = workspace:FindPartOnRayWithIgnoreList(ray, ig)
if part then
local shockwave = game:GetService("ReplicatedStorage").Kamehameha.Shockwave:Clone()
shockwave.Position = hit
shockwave.Parent = workspace.FX
game.Debris:AddItem(shockwave, 2)
firetrack.Looped = true
chargetrack:Stop(0)
local t = ts:Create(shockwave, TweenInfo.new(0.6, Enum.EasingStyle.Sine), {
Transparency = 1;
Size = shockwave.Size * 1.6;
CFrame = shockwave.CFrame * CFrame.Angles(0,math.rad(180),0) * CFrame.new(0,5.2,0)
})
t:Play()
t.Completed:Connect(function()
t:Destroy()
shockwave:Destroy()
end)
end
end
local function ExplosionWave(item, t)
if t.PlaybackState == Enum.PlaybackState.Delayed then
Shockwave(item)
end
end
local function Added(item)
if item.Name == "Shock" then
coroutine.resume(coroutine.create(function()
local n = 1
while item:isDescendantOf(workspace.FX) do
item.CFrame = item.CFrame * CFrame.Angles(0,math.rad(n),0)
if n <= 9 then n = n + 0.5 end
rs.Heartbeat:Wait()
end
end))
elseif item.Name == "Explosion" then
item:WaitForChild("In") item:WaitForChild("Out")
for i,v in pairs(item:GetChildren()) do
local t = ts:Create(v, TweenInfo.new(0.15, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 4, true, 0.1), {
Size = v.Size * 1.5;
Transparency = 0.5;
})
t:Play()
Shockwave(item)
local ss = t:GetPropertyChangedSignal("PlaybackState"):Connect(function()
ExplosionWave(item, t)
end)
t.Completed:Connect(function()
ss:Disconnect()
t:Destroy()
local t = ts:Create(v, TweenInfo.new(0.4, Enum.EasingStyle.Sine), {
Size = v.Size * 2;
Transparency = 1;
})
t:Play()
t.Completed:Connect(function()
t:Destroy()
v:Destroy()
end)
end)
end
end
end
uis.InputBegan:Connect(ButtonDown)
uis.InputEnded:Connect(ButtonUp)
workspace.FX.DescendantAdded:Connect(Added)
deleteab.OnClientEvent:Connect(function()
script:Destroy()
end)
this is the local script for it, there is also a server script for it which i can also give, how can i implement it into mobile?