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

GetTouchingParts is not a valid member of Model?

Asked by 5 years ago

So I made a script to shoot a fireball, and the parts I want to be touched I want to test to have the touched parts have the same fire ParticleEmitter thats on the fireball. I tried using :GetTouchingParts() and it says "GetTouchingParts is not a valid member of Model" when I try shooting the fireball on a test dummy. Don't judge me with my variables btw lol

local Comet = game.ReplicatedStorage.Comet
Comet.OnServerInvoke = function(player)

    print("working!")
    local char = player.Character
    local hum = char.Humanoid
    local magic = game.ReplicatedStorage.circle
    local cframe = char.Torso.CFrame*CFrame.new(0, 0, -5)
    local rootpart = char.Torso
    local Mouse = player:GetMouse()
    local torso = char.HumanoidRootPart
    char.Humanoid.AutoRotate = false
    game:GetService("Chat"):Chat(char.Head, "White-Ember Sphere!")
    --Cast animation--
    torso.CFrame = CFrame.new(torso.Position, Mouse.Hit.p*Vector3.new(1,0,1) + torso.Position*Vector3.new(0, 1, 0))
    torso.Anchored = true
    print("anim")
    local anim = script:WaitForChild("Anim")
    local animTrack = hum:LoadAnimation(anim)
    animTrack:Play()
    --Magic Circle (update decal with ring)--
    print("magic circle")
    local circle = magic:Clone()
    circle.Parent = game.Workspace
    circle.Name = "MagicCircle"
    circle.Anchored = true
    circle.CanCollide = false
    circle.CFrame = char.Torso.CFrame*CFrame.new(0,0,-2.5)
    for i = 1, 12 do
        circle.Size = circle.Size + Vector3.new(0.75,.75,0)

        wait()
    end
    --Fireball itself--
    local p = Instance.new("Part")
    p.Parent = game.Workspace.fireball
    p.CFrame = CFrame.new(rootpart.position)
    p.TopSurface = "Smooth" 
    p.BottomSurface = "Smooth" 
    p.Shape = Enum.PartType.Ball 
    p.Size = Vector3.new(2, 2, 2) 
    p.Transparency = 1
    p.CanCollide = false
    p.Material = "Neon"
    p.BrickColor = BrickColor.new("Neon green")

    --White Flames--
    local fire = Instance.new("ParticleEmitter")
    fire.Size = NumberSequence.new(2)
    fire.Transparency = NumberSequence.new(0.5)
    fire.LightEmission = 0.3
    fire.Rate = 2860
    fire.Parent = p
    fire.Acceleration = Vector3.new(0,0,0)
    fire.Lifetime = NumberRange.new(0.2)
    fire.Speed = NumberRange.new(1)
    fire.Rotation = NumberRange.new(-360,360)
    fire.RotSpeed = NumberRange.new(-360,360)
    fire.Texture = "http://www.roblox.com/asset/?id=296874871"
    --Add Sound--
    local woosh = Instance.new("Sound")
    woosh.SoundId = "rbxassetid://463598785"
    woosh.Volume = 10
    woosh.MaxDistance = 250000
    woosh.EmitterSize = 1
    woosh.Parent = p
    woosh.Playing = true
    --BodyVelocity--
    local bv = Instance.new("BodyVelocity")
    bv.Parent = p 
    bv.Velocity = (Mouse.Hit.p - rootpart.Position).unit*100
    bv.P = 3000
    bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
    game:GetService("Debris"):AddItem(p, 7)
    --Damage Function--
    p.Touched:Connect(function(hit)
        if hit == circle then return end
        p:Destroy()
        local new = Instance.new("Part")
        new.Shape = "Ball"
        new.BrickColor = BrickColor.new("Deep orange")
        new.Anchored = true
        new.CanCollide = false
        new.Material = "Neon"
        new.Parent = game.Workspace.fireball
        new.Position = p.Position
        for i = 1, 50 do
            new.Size = new.Size + Vector3.new(.25,.25,.25)
            new.Transparency = new.Transparency + 0.03
            wait(0.05)
        end
        local pe = fire:Clone()
        local parts = hit.Parent:GetTouchingParts()
        for _, p in next, parts do
            pe.Parent = p
        end


    end)

     --Destroy circle--
wait(1.5)
circle:destroy()
char.Humanoid.AutoRotate = true
torso.Anchored = false
    end

1 answer

Log in to vote
0
Answered by
WXBZ 3
5 years ago

GetTouchingParts can only be used as a function for BaseParts. If you do a for in pairs loop and use that function for every part then it should function correctly.

0
so maybe I could make a table with character part names and use that table in a for i loop? ScrubSadmir 200 — 5y
0
You can do that, or you can make a FindInTable function to see if a touching part is a descendant of a character. WXBZ 3 — 5y
0
how would i do that exactly? I dont really understand what you meant, if thats the name of the function, or its purpose or whatever? ScrubSadmir 200 — 5y
Ad

Answer this question