I have this small function for my game
local function onTouch(partTouched)
local canHarvest = partTouched.Parent:FindFirstChild("CanHarvest")
local valuableSpace = partTouched.Parent:FindFirstChild("SpaceTaken")
local valuableRT = partTouched.Parent:FindFirstChild("RespawnTime")
local cost = partTouched.Parent:FindFirstChild("Cost")
if canHarvest then
if canHarvest.Value == true and playerValuables.Value < playerStorage.Value then
playerValuables.Value = playerValuables.Value + valuableSpace.Value -- Space taken in storage playerStat after the action
playerMIS.Value = playerMIS.Value + cost.Value -- How much money are there in MoneyInStorage playerStat after the action
canHarvest.Value = false
partTouched.Transparency = 1
partTouched.CanCollide = false
wait(valuableRT.Value)
canHarvest.Value = true
partTouched.Transparency = 0
partTouched.CanCollide = true
end
end
end
mainDrill.Touched:Connect(onTouch)
it's working fine but whenever I try to put wait(time) anywhere so my function will rest time seconds before it can function again it just doesn't work
