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

Making a Custom tool for a client, How is this script not working? [closed]

Asked by 7 years ago
Edited 7 years ago
player = game.Player.LocalPlayer
mouse = player:GetMouse()
firing = false
Canfire= true
reload = 5
damage = 35
rate = 5
script.Parent.Activated:connect(function()
    if Canfire == true then
        firing = true
        repeat local arrow = Instance.new("Part", workspace)
            arrow.CanCollide = false
            arrow.Shape = "Block"
            arrow.Size = Vector3.new(0.4,0.4,0.4)
            arrow.BrickColor = BrickColor.new(175,0,0)
            arrow.CFrame = CFrame.new(script.Parent.Handle.Position, mouse.Hit.p)
            local v = Instance.new("BodyVelocity", arrow)
            v.Velocity = arrow.CFrame.lookVector*50
            game.Debris:AddItem(arrow,15)
            arrow.Touched:connect(function(hit)
                if hit.Parent ~= player.Character and hit.Parent:FindFirstChild("Humanoid")
                    then hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - damage
                    arrow:Destroy()
            end
            end)
        until firing == false
    end

end)
script.Parent.Deactivated:connect(function()
    if firing == true then
        firing = false
    end
end)
mouse.Keydown:connect(function(key)
    Canfire = false
    wait(reload)
    Canfire = true
end)

That is my script for firing from a Union Handled Tool, I have no idea what is wrong with it, I am a horrid scripter.

0
Format your code in code block, please. Goulstem 8144 — 7y
0
Does it give any errors in studio output? shadownetwork 233 — 7y
0
Nothing but Player is not a valid member of DataModel and Script analysis came up nothing. poopy123guy 0 — 7y

Closed as Non-Descriptive by Goulstem

This question has been closed because its title or content does not adequately describe the problem you are trying to solve.
Please ensure that your question pertains to your actual problem, rather than your attempted solution. That is, you were trying to solve problem X, and you thought solution Y would work, but instead of asking about X when you ran into trouble, you asked about Y.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

This is not an answer it is an correction.

When posting on this site all of your code should be in a code block

Also everything should be on separate lines and tabbed.

Now maybe this would make it easy to find your own error.

player = game.Player.LocalPlayer
mouse = player:GetMouse()
firing = false 
Canfire= true
reload = 5 
damage = 35 
rate = 5 

script.Parent.Activated:connect(function() 
    if Canfire == true then 
        firing = true 
        repeat 
            local arrow = Instance.new("Part", workspace) 
            arrow.CanCollide = false 
            arrow.Shape = "Block" 
            arrow.Size = Vector3.new(0.4,0.4,0.4) 
            arrow.BrickColor = "Persimmon" 
            arrow.CFrame = CFrame.new(script.Parent.Handle.Position, mouse.Hit.p) 
            local v = Instance.new("BodyVelocity", arrow) 
            v.Velocity = arrow.CFrame.lookVector*50 
            game.Debris:AddItem(arrow,15) 
            arrow.Touched:connect(function(hit)
                if hit.Parent ~= player.Character and hit.Parent:FindFirstChild("Humanoid") then
                    hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - damage
                    arrow:Destroy() 
                end
            end)
        until firing == false 
    end
end) 

script.Parent.Deactivated:connect(function() 
    if firing == true then 
        firing = false 
    end 
end) 

mouse.Keydown:connect(function(key)
    Canfire = false
    wait(reload)
    Canfire = true
end)
0
kk I'm a little new to this so. poopy123guy 0 — 7y
Ad