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

Starter character script not working?

Asked by
linkad1 -7
4 years ago

So I made a script that I know that works, as I put the script inside other objects, and it works. But, the problem is for some reason, if I try to put it inside of my starter character, which I am putting the script inside of each part of the player model, and it doesn't work. I have the starter model setup, with each part correctly named. I have the script here, although it is a bit messy.

function onTouched(hit)
    if hit.Parent:findFirstChild("Humanoid") then
        hit:Destroy();
        local sound = Instance.new("Sound")
        sound.SoundId = "rbxasset://sounds\\Rocket shot.wav"
        sound.Parent = script.Parent
        sound.Volume = 1
        sound:play()
        explosion = Instance.new("Explosion")
        explosion.BlastRadius = 12
        explosion.BlastPressure = 1000000 -- these are really wussy units

        -- find instigator tag
        local creator = script.Parent:findFirstChild("creator")
        explosion.Position = script.Parent.Position
        explosion.Parent = game.Workspace
        script.Parent:Destroy();

    end

end

script.Parent.Touched:connect(onTouched)

1 answer

Log in to vote
0
Answered by
A_Mp5 222 Moderation Voter
4 years ago

Try adding some waits, or maybe use ~= if humanoid nil, and not an "if"

0
What line? linkad1 -7 — 4y
Ad

Answer this question