Рет қаралды 357
Script in the ball:
-- Get the part
local part = script.Parent
-- Get the sound
local sound = part:FindFirstChild("Sound1")
-- Debounce variable
local isTouched = false
-- Function to handle the touch event
local function onTouch(otherPart)
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
if humanoid and not isTouched then
-- Set debounce
isTouched = true
-- Play the sound
if sound and sound:IsA("Sound") then
sound:Play()
end
-- Apply force to the part to make it move in the direction the player kicked it
local direction = (part.Position - humanoid.Parent.HumanoidRootPart.Position).Unit
local forceMagnitude = math.random(20, 40) -- Change this value to control the force applied
local force = direction * forceMagnitude
part.Velocity = Vector3.new(force.X, part.Velocity.Y, force.Z)
-- Reset debounce after a delay
wait(1) -- Change this value to control the debounce time
isTouched = false
end
end
-- Connect the function to the part's Touched event
part.Touched:Connect(onTouch)
The scripts : pastebin.com/u...
The sound ID: 9119328220