Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

1 comment

0

explien more plz

1 answer

✓ Accepted answer

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!

2 comments

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....

0

it wouldn't, as it's enclosed in the function. Loops in functions don't stall onto another.

This discussion is preserved as it was. New answers, comments, and votes are closed.