#Need to add sound

13 messages · Page 1 of 1 (latest)

tulip python
#

local tool = script.Parent
local debounce = false
local deployDelay = 0.5

local function activateTrap(player)
if debounce then
return
end
debounce = true

wait(deployDelay)

local character = player.Character
if not character then
    debounce = false
    return
end

local humanoidRootPart = character:WaitForChild("HumanoidRootPart")


local humanoid = character:FindFirstChildOfClass("Humanoid")
if not humanoid or humanoid:GetState() == Enum.HumanoidStateType.Freefall then
    debounce = false

    return
end


local handle = tool.Trap:Clone()


local playerPosition = humanoidRootPart.Position
local playerDirection = humanoidRootPart.CFrame.LookVector
local newPosition = playerPosition + playerDirection * 7


newPosition = newPosition - Vector3.new(0, 2.9, 0)


handle.Position = newPosition
handle.Anchored = true
handle.Parent = workspace  


local mainPart = tool:FindFirstChild("MainPart")
if mainPart then
    local clonedTool = tool:Clone()
    clonedTool.Parent = workspace  
    clonedTool:SetPrimaryPartCFrame(CFrame.new(newPosition))
end


tool:Destroy()

debounce = false

end

tool.Activated:Connect(function()
local player = game.Players:GetPlayerFromCharacter(tool.Parent)
if player then
activateTrap(player)
end
end)

cunning peak
#

add a sound instace as a children in workspace

#

add ur soundid into the sound

tulip python
#

i did already

cunning peak
#

define ur sound as a variable in ur script, smth like local sound = script:WaitForChild(“sound”)

#

and then do

#

sound:Play()

#

to play the sound

tulip python
#

Yeah ive tried that many times but i just dont know where to place it

#

because where i place that in the script is pretty important

cunning peak
#

idk man just place it right after the line of code that fixate ur trap to the ground

tulip python
#

shi thanks it worked

quaint shellBOT
#

studio** You are now Level 2! **studio