I made a local script in a tool where it creates a particle effect and a hit box that deals damage in front of the player. Everything works great. But, for some reason the player can’t move when the flamethrower is activated, (the tool). Here’s the script, its located in a tool in starterpack…
local tool = script.Parent
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local root = character:WaitForChild("HumanoidRootPart")
local canshoot = true
function OnActivation()
if canshoot == true then
canshoot = false
--local sound = script.Parent.Thunder
--sound:Play()
print('Activation works')
local ball = Instance.new("ParticleEmitter")
ball.Texture = 'http://www.roblox.com/asset/?id=290556384'
ball.Color = ColorSequence.new{
ColorSequenceKeypoint.new(0, Color3.new(1, 0, 0)),
ColorSequenceKeypoint.new(0.33, Color3.new(1, 0.666667, 0)),
ColorSequenceKeypoint.new(0.66, Color3.new(1, 1, 0)),
ColorSequenceKeypoint.new(1, Color3.new(1, 0.945098, 0.721569))
}
ball.Lifetime = NumberRange.new(1,2)
ball.Rate = 100
ball.Speed = NumberRange.new(30,30)
ball.SpreadAngle = Vector2.new(15,15)
ball.Parent = root.Fire
local ball2 = Instance.new("Part")
ball2.Shape = Enum.PartType.Block
ball2.Size = Vector3.new(6,3.5,13.2)
ball2.Transparency = 0
ball2.Massless = true
ball2.CanCollide = false
ball2.Parent = workspace
ball2.Anchored = false
local newCFrame = root.CFrame * CFrame.new(Vector3.new(0,0,-7))
local cf = ball2.CFrame
ball2.CFrame = newCFrame
local weld = Instance.new("WeldConstraint")
weld.Parent = root
weld.Part0 = root
weld.Part1 = ball2
local Velocity = Instance.new("BodyVelocity")
Velocity.maxForce = Vector3.new(math.huge, math.huge, math.huge)
Velocity.Velocity = ball2.CFrame.lookVector * 0
Velocity.Parent = ball2
ball2.Touched:connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') and hit.Parent ~= player.Character then
local humanoid1 = hit.Parent:FindFirstChild('Humanoid')
humanoid1:TakeDamage(20)
end
end)
ball2.Touched:connect(function(hit)
if hit:IsA("Part") and hit.Parent ~= player.Character then
wait(.5)
end
end)
wait(10)
ball2:Destroy()
ball:Destroy()
wait(3)
canshoot = true
end
end
tool.Activated:Connect(OnActivation)