The script works perfectly fine in studio but when I play the game, it crashes the moment I try to enter.

while true do wait(0.1) if script.Parent.Humanoid.Health == 0 then local maths = math.random(1, 1)
local tool = game.ReplicatedStorage.Rats:FindFirstChild("Poison") local nothing = game.ReplicatedStorage.Rats:FindFirstChild("Nothing")

if maths == 1 then
    local toolc = tool:Clone()
    toolc.Parent = game.Workspace
    toolc.Handle.CFrame = script.Parent.Head.CFrame + Vector3.new(5,2,0)
    script:remove()
else if maths == 2 then
    local nothingc = nothing:Clone()
    nothingc.Parent = game.Workspace
    nothingc.Handle.CFrame = script.Parent.Head.CFrame + Vector3.new(0,-200,0) 
    script:remove()
else if maths == 3 then
    local nothingc = nothing:Clone()
    nothingc.Parent = game.Workspace
    nothingc.Handle.CFrame = script.Parent.Head.CFrame + Vector3.new(0,-200,0)
    script:remove()
else if maths == 4 then
    local nothingc = nothing:Clone()
    nothingc.Parent = game.Workspace
    nothingc.Handle.CFrame = script.Parent.Head.CFrame + Vector3.new(0,-200,0)
    script:remove()
else if maths == 5 then
    local nothingc = nothing:Clone()
    nothingc.Parent = game.Workspace
    nothingc.Handle.CFrame = script.Parent.Head.CFrame + Vector3.new(0,-200,0)
    script:remove()
else if maths == 6 then
    local nothingc = nothing:Clone()
    nothingc.Parent = game.Workspace
    nothingc.Handle.CFrame = script.Parent.Head.CFrame + Vector3.new(0,-200,0)

wait(1) end end end end end end end end

3 comments

0

Something happened trying to copy and paste, sorry about that..

0

Um, I'm failing to see how your variable maths gets to 2, or 3 if you set it to math.random(1,1) which means it will only be one?

0

use Destroy() instead of remove()