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

why isnt the rocochet noise not playing when it doesent hit another person?

Asked by
Tizzel40 243 Moderation Voter
5 years ago

This my script for my pisol and I want the the ricochet noise to play when it hits a part that's not the humanoid's body but it doesn't play... help...

The Problem rly is through lines 35 through 57

local tool = script.Parent.Parent
local remote = tool.Remotes.shootevent
local hand = tool.Handle
local hit = false
---////--[Variables]--///-------------------------
local config = tool.Configuration
local ammo = config.Ammo       
local Maxammo = config.MaxAmmo
local Animations = tool.Animations
local hithum = false
local ting1 = false

remote.OnServerEvent:Connect(function(plr,mousehit)
    ting1 = false
    hithum = false
    local char = plr.Character or plr.CharacterAdded:wait()
    local hum = char.Humanoid         
    ----------=plr.Data:WaitForChild("Devilf").Value = "MaguFruit"
    local function GetBullet()
        local p = config.Bullet:Clone()
        return p
    end
---local mh = mouse.hit
local bullet = GetBullet()
bullet.Parent = game.Workspace
hand.Sound:Play()
local bodyv = game.ReplicatedStorage.BodyVelocity:Clone()
bodyv.Parent = bullet
bullet.CFrame = script.Parent.Parent.hole.CFrame ---* CFrame.new(char.HumanoidRootPart.CFrame.lookVector * -2)
    bullet.CFrame = CFrame.new(bullet.Position, mousehit.p)
    bullet.BodyVelocity.Velocity = bullet.CFrame.LookVector * 285



    bullet.Touched:Connect(function(hit)
    local ehum = hit and hit.Parent:FindFirstChild("Humanoid")--:FindFirstChild("Humanoid") 
    if ehum and ehum ~= hum then 
        if hithum == false then
            hithum = true

        hit.Parent.Humanoid:TakeDamage(18)
    --- wait(.3)
        ----bullet:Destroy()

        else

            bullet.ricochet:Play()
     print("ting")
        end
    end

        wait(2)
    bullet:Destroy()

    ---end
    end)
        end)

Answer this question