- What do you want to achieve?
making the balls get smaller when the player touches them.
- What is the issue? Include screenshots / videos if possible!
When the player plays them at a normal speed, they work fine, but when the player plays them at a very slow speed, it doesn’t work as it should.
- What solutions have you tried so far??
Place a variable so that the touch would not be executed so many times but it did not work
This is the ball code.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Module = require(ReplicatedStorage.Modules.SnowMoneyModule)
local BallTouchedSound = game.StarterPlayer.StarterPlayerScripts.Sounds.SnowBall
local SnowBall = script.Parent
local OriginalPosition = SnowBall.Position
local OriginalSize = SnowBall.Size
local SoundActivated = false
local debounce = false
local function SmallBall()
for i = 1,100 do
wait(0.00001)
SnowBall.Size = SnowBall.Size - Vector3.new(0.1,0.1,0.1)
SnowBall.Position = SnowBall.Position + Vector3.new(0,0.2,0)
end
end
SnowBall.Touched:Connect(function(hit)
local Humanoid = hit.Parent:FindFirstChild("Humanoid")
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if Humanoid and Player then
debounce = true
if SoundActivated == false then
SoundActivated = true
BallTouchedSound:Play()
wait(1)
SoundActivated = false
end
SmallBall()
-- wait(5)
-- SnowBall.Position = OriginalPosition
-- SnowBall.Size = OriginalSize
end
end)