Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

when i git the part it wont kill me i the script is not disabled no errors how do i fix?

Asked by 5 years ago
local plr = game.Players.LocalPlayer
local InputService = game:GetService("UserInputService")
local cam = game.Workspace.CurrentCamera
local gocam = false
InputService.InputBegan:Connect(function(input)
    local key = input.KeyCode --Gets the key that the player pressed
    if key == Enum.KeyCode.Q then --Checks if the key is Q
   local fly = true

    local char = plr.Character 
    local i = game.Lighting.death:Clone()
    i.Parent = workspace
    local ies = true
i.Position = char.Head.Position + Vector3.new(0,4,0)
i.Anchored =  true
i.Name = "Fire"
i.CanCollide = true


    fly = false
    print("tested")
    local q = game.Players.LocalPlayer.Character
    local b = Instance.new("BodyVelocity",i)
    while ies == true do
        wait()
    local mouse = plr:GetMouse()
    b.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
     i.CFrame = CFrame.new(i.Position, mouse.Hit.Position)
    i.Anchored = false
    b.Velocity = mouse.Hit.LookVector * 23 --q.Head.CFrame.LookVector * 232--
    cam.CameraSubject = i
    end
    -- damage wont work 
    i:Connect(function(hit)

    local humanoid = hit.Parent:FindFirstChild("Humanoid") 
    if (humanoid ~= nil) then   -- if a humanoid exists, then
        humanoid:TakeDamage(23) -- damage the humanoid
        i:Destroy()
        --
    end
0
explien more plz User#23365 30 — 5y

1 answer

Log in to vote
1
Answered by
Lugical 425 Moderation Voter
5 years ago
Edited 5 years ago

What I'm seeing is that you haven't placed enough end blocks in your code. Without them, the code is pretty much not able to run right.

local plr = game.Players.LocalPlayer
local InputService = game:GetService("UserInputService")
local cam = game.Workspace.CurrentCamera
local gocam = false
InputService.InputBegan:Connect(function(input)
    local key = input.KeyCode --Gets the key that the player pressed
    if key == Enum.KeyCode.Q then --Checks if the key is Q
   local fly = true

    local char = plr.Character 
    local i = game.Lighting.death:Clone()
    i.Parent = workspace
    local ies = true
i.Position = char.Head.Position + Vector3.new(0,4,0)
i.Anchored =  true
i.Name = "Fire"
i.CanCollide = true


    fly = false
    print("tested")
    local q = game.Players.LocalPlayer.Character
    local b = Instance.new("BodyVelocity",i)
    while ies == true do
        wait()
    local mouse = plr:GetMouse()
    b.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
     i.CFrame = CFrame.new(i.Position, mouse.Hit.Position)
    i.Anchored = false
    b.Velocity = mouse.Hit.LookVector * 23 --q.Head.CFrame.LookVector * 232--
    cam.CameraSubject = i
    end
    end --You need this end to end the previous if statement.
end) --Add this "end)" to stop the previous function.
    -- damage wont work 
    i:Connect(function(hit)

    local humanoid = hit.Parent:FindFirstChild("Humanoid") 
    if (humanoid ~= nil) then   -- if a humanoid exists, then
        humanoid:TakeDamage(23) -- damage the humanoid
        i:Destroy()
    end
end) -- You need this to end a function.

All in all, just make sure you have your ends done. Also, as a side note, Lighting shouldn't be used a storage space, so keep that in mind.

If there's anything else wrong, please let me know so I can fix it!

0
On line 24/25 there’s a while true statement causing a wait that never becomes false, so that may be an issue as well.... DinozCreates 1070 — 5y
0
it wouldn't, as it's enclosed in the function. Loops in functions don't stall onto another. Lugical 425 — 5y
Ad

Answer this question