Advertisement
Tweak16

ROBLOX Scripting | Coins | Local Script

Aug 3rd, 2021
2,931
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.14 KB | None | 0 0
  1. --[[
  2. Made by Tweakified, Neonblox Games
  3. YouTube Tutorial: https://youtu.be/RM6v_fQKx9w
  4. Discord Support: https://discord.com/invite/JdaFf7p
  5. Server Script: https://pastebin.com/kP0PpT74
  6.  
  7. Script Type: LocalScript
  8. Script Parent: StarterPlayer > StarterPlayerScripts
  9. --]]
  10.  
  11. local TweenService = game:GetService("TweenService")
  12. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  13. local Players = game:GetService("Players")
  14.  
  15. local player = Players.LocalPlayer
  16. local GetCoin = ReplicatedStorage:WaitForChild("GetCoin")
  17. local CoinPickupEffect = workspace:WaitForChild("CoinPickupEffect")
  18. local CoinsFolder = workspace:WaitForChild("Coins")
  19.  
  20. local CoinTween1Info = TweenInfo.new(0.2)
  21. local CoinTween2Info = TweenInfo.new(0.2)
  22. local CoinTween3Info = TweenInfo.new(0.35)
  23. local CoinRotationTweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Linear)
  24.  
  25. local RotationTweens = {}
  26.  
  27. GetCoin.OnClientEvent:Connect(function(Coin)
  28.     local OldRotationTween = RotationTweens[Coin.Name]
  29.     if OldRotationTween ~= nil then
  30.         OldRotationTween:Cancel()
  31.     end
  32.    
  33.     local TempTween1 = TweenService:Create(Coin, CoinTween1Info, {CFrame = (Coin.CFrame + Vector3.new(0, 5, 0)) * CFrame.Angles(math.rad(120), 0, 0)})
  34.     local TempTween2 = TweenService:Create(Coin, CoinTween2Info, {CFrame = (Coin.CFrame + Vector3.new(0, 10, 0)) * CFrame.Angles(math.rad(240), 0, 0)})
  35.     local TempTween3 = TweenService:Create(Coin, CoinTween3Info, {CFrame = (Coin.CFrame + Vector3.new(0, 15, 0)) * CFrame.Angles(math.rad(360), 0, 0)})
  36.    
  37.     CoinPickupEffect:Play()
  38.    
  39.     TempTween1:Play()
  40.     TempTween1.Completed:Wait()
  41.     TempTween2:Play()
  42.     TempTween2.Completed:Wait()
  43.     TempTween3:Play()
  44.     spawn(function()
  45.         while Coin.Transparency < 1 do
  46.             wait(0)
  47.             Coin.Transparency = Coin.Transparency + 0.1
  48.         end
  49.     end)
  50.    
  51.     Coin:Destroy()
  52. end)
  53.  
  54. repeat wait(0.1) until player:FindFirstChild("coindata") ~= nil
  55. local CoinData = player:FindFirstChild("coindata")
  56.  
  57. for _, Coin in pairs(CoinsFolder:GetChildren()) do
  58.     spawn(function()
  59.         local CollectedCoin = CoinData:WaitForChild(Coin.Name)
  60.         local TempTween1 = TweenService:Create(Coin, CoinRotationTweenInfo, {CFrame = Coin.CFrame * CFrame.Angles(math.rad(120), 0, 0)})
  61.         local TempTween2 = TweenService:Create(Coin, CoinRotationTweenInfo, {CFrame = Coin.CFrame * CFrame.Angles(math.rad(240), 0, 0)})
  62.         local TempTween3 = TweenService:Create(Coin, CoinRotationTweenInfo, {CFrame = Coin.CFrame * CFrame.Angles(math.rad(360), 0, 0)})
  63.         while CollectedCoin.Value == false do
  64.             TempTween1:Play()
  65.             RotationTweens[Coin.Name] = TempTween1
  66.             TempTween1.Completed:Wait()
  67.             if CollectedCoin.Value == false then
  68.                 TempTween2:Play()
  69.                 RotationTweens[Coin.Name] = TempTween2
  70.                 TempTween2.Completed:Wait()
  71.                 if CollectedCoin.Value == false then
  72.                     TempTween3:Play()
  73.                     RotationTweens[Coin.Name] = TempTween3
  74.                     TempTween3.Completed:Wait()
  75.                 end
  76.             end
  77.         end
  78.     end)
  79. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement