So, I have been trying to make it so that my projectile will launch once a person taps on their mobile screen, but so far the code I have been using is not working. I have tried solving the problem by doing different variations of the code, but it still has not worked. I am not asking you to do the work for me, but if you could explain how to fix it and what I did wrong, that would be really appreciated! Also, the output bar isnt saying I have any errors.
P.S. I am super sorry if this question may seem bad or dumb, and if my code is super ugly and messy and hard to read, its because I just started scripting, yes thats my excuse :3
Code:
local Player = game.Players.LocalPlayer
local char = Player.Character or Player.CharacterAdded:Wait()
local head = char:WaitForChild("Head")
local ammo = 1
local x = Instance.new("Part")
x.BrickColor = BrickColor.new("Institutional white")
x.Material = "Neon"
x.TopSurface = "Smooth"
x.BottomSurface = "Smooth"
x.Anchored = false
x.CanCollide = true
x.Transparency = 0.1
x.Size = Vector3.new(3,2,2);
x.RotVelocity = Vector3.new(10,10,10)
local particle = Instance.new("ParticleEmitter")
particle.Texture = "rbxgameasset://Images/Purplish Pink Smoke Magic"
particle.Rate = 50
particle.Speed = NumberRange.new(70)
particle.Size = NumberSequence.new(1)
particle.Lifetime = NumberRange.new(1,2)
particle.RotSpeed = NumberRange.new(0)
particle.VelocitySpread = NumberRange.new(50)
particle.LightEmission = NumberRange.new(100)
particle.LightInfluence = NumberRange.new(6)
local z = Instance.new("Explosion")
game:GetService("UserInputService").TouchTap:connect(function(input)
if input.TouchTap == true then
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/asset/?id=855830361"
local humanoid = script.Parent:WaitForChild('Humanoid')
humanoid:LoadAnimation(animation):Play()
wait(.2)
if ammo == 1 then
ammo = 0
local cl = x:Clone()
cl.Parent = game.Workspace
cl.CFrame = Player.Character.UpperTorso.CFrame * CFrame.new(0,2,-7)
local clp = particle:Clone()
clp.Parent = cl
cl.Anchored = true
local v = Instance.new("BodyVelocity")
v.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
v.Velocity = Player.Character.UpperTorso.CFrame.lookVector * 90
for i=1, 5 do
cl.Size = cl.Size + Vector3.new(0.4,0.4,0.4)
wait(0.5)
end
v.Parent = cl
cl.Anchored = false
cl.Touched:connect(function(hit)
z.Parent = game.Workspace
z.Position = cl.Position
cl:Destroy()
end)
wait(4)
cl:Destroy()
wait(.1)
ammo = 1
end
end
end)
Code that is killing me:
game:GetService("UserInputService").TouchTap:connect(function(input)
if input.TouchTap == true then
