Hi! watch this video:
robloxapp-20200418-1700065.wmv (692.9 KB)
and here is my output printing out “hit” every time I hit the coin:
but I want to make it so I can only touch the coin once and any further touch is not detected. Here is my script:
local coins = workspace.Coins:GetChildren()
local tw = game:GetService("TweenService")
local info = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.In, math.huge, true, 0)
local info2 = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
for i, v in pairs(coins) do
local goal = {Position = v.End.Position}
local tween = tw:Create(v.Coin, info, goal)
tween:Play() -- DEFOULT TWEENING
v.Coin.Touched:Connect(function(hit)
print(hit)
local goal2 = {Position = v.Fade.Position}
local tween2 = tw:Create(v.Coin, info2, goal2)
tween2:Play() -- TWEEN THAT PLAYS WHEN I TOUCH A COIN
for i = 0, 1, 0.01 do -- THIS MAKES A COIN FADE
wait()
v.Coin.Transparency = i
end
v:Destroy() -- DESTROYING THE COIN MODEL
coins = workspace.Coins:GetChildren() -- CLEARING THE COIN MODEL FROM THE TABLE
end)
end
game:GetService("RunService").Heartbeat:Connect(function(frame)
for i, v in pairs(coins) do -- FOR EVERY COIN IN THE TABLE DO SPINNING
v.Coin.CFrame = v.Coin.CFrame * CFrame.Angles(math.rad(1)*frame*60, 0, 0)
end
end)
I already have tried debounce outside the for loop, but its pointless:
robloxapp-20200418-1711295.wmv (2.1 MB)
and if make debounce inside the touched function then I am setting it every time I touch a coin back to false and that’s not great either… Thanks for ur help!
Also here is my workspace:
script is inside of ServerScriptService.