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

How do i find a localplayer without a nil value? [closed]

Asked by 5 years ago
  1. Not LocalScript
  2. why its a nil value?
  3. I never using a "game.player.localplayer"
local updateInterval = .4
local currentColor = 1
local colors = {26, 21}
local Tool = script.Parent 
local damage = 1

local ticksound = Instance.new("Sound")
ticksound.SoundId = "rbxasset://sounds\\clickfast.wav"
ticksound.Parent = script.Parent

function update()
    updateInterval = updateInterval * .9
    script.Parent.BrickColor = BrickColor.new(colors[currentColor])
    currentColor = currentColor + 1
    if (currentColor > 2) then currentColor = 1 end
end


function blowUp()
    local sound = Instance.new("Sound")
        sound.SoundId = "rbxasset://sounds\\Rocket shot.wav"
        sound.Parent = script.Parent
        sound.Volume = 1
        sound:play()
    local explosion = Instance.new("Explosion")
    explosion.BlastRadius = 12
    explosion.BlastPressure = 0 -- these are really wussy units

    -- find instigator tag
    local creator = script.Parent:findFirstChild("creator")
    if creator ~= nil then
        explosion.Hit:connect(function(part, distance)  onPlayerBlownUp(part, distance, creator) end)
    end

    explosion.Position = script.Parent.Position
    explosion.Parent = game.Workspace
    script.Parent.Transparency = 1
end

function onPlayerBlownUp(part, distance, creator)
    if part.Name == "Head" then
        local humanoid = part.Parent.Human
        local vCharacter=Tool.Parent
        local vPlayer=game.Players:playerFromCharacter(vCharacter)
        local MinDamageValue = (vPlayer.Data.Stats.Power.Value/2+vPlayer.Data.Boost.BoostPower.Value/2+vPlayer.Armor.Power.Value/2)
        local MaxDamageValue = (damage+vPlayer.Data.Stats.Power.Value*4+vPlayer.Data.Boost.BoostPower.Value*4+vPlayer.Armor.Power.Value*4)
        local Damage = math.random(MinDamageValue,MaxDamageValue*(255-humanoid.Parent.EnemySettings.Defend.Value-1)/256)+1
        humanoid.Health = humanoid.Health - Damage
        tagHumanoid(humanoid, creator)
    end
end

function tagHumanoid(humanoid, creator)
    -- tag does not need to expire iff all explosions lethal    
    if creator ~= nil then
        local new_tag = creator:clone()
        new_tag.Parent = humanoid
    end
end

function untagHumanoid(humanoid)
    if humanoid ~= nil then
        local tag = humanoid:findFirstChild("creator")
        if tag ~= nil then
            tag.Parent = nil
        end
    end
end

while updateInterval > .1 do
    wait(updateInterval)
    update()    
    ticksound:play()    
end

blowUp()
wait(2)
script.Parent:remove()

0
Wait what? Be more descriptive. ben0h555 417 — 5y
1
free model cxodesss User#24403 69 — 5y

Closed as Not Constructive by User#24403

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?