Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ToolHandler
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local RemoteEvents = ReplicatedStorage.RemoteEvents
- local CoinClicked = RemoteEvents.CoinClicked
- CoinClicked.OnServerEvent:Connect(function(player, Strength)
- if player.PlayerStats.CurrentValue.Value < player.PlayerStats.Storage.Value then
- player:WaitForChild("PlayerStats").CurrentValue.Value = player.PlayerStats.CurrentValue.Value + Strength
- end
- end)
- TeleportHandler
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local RemoteEvents = ReplicatedStorage.RemoteEvents
- local TeleportToShop = RemoteEvents.TeleportToShop
- TeleportToShop.OnServerEvent:Connect(function(Player)
- local Character = Player.Character
- Character:MoveTo(game.Workspace.SellButton.Position + Vector3.new (0,1,0))
- end)
- SellHandler
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local RemoteEvents = ReplicatedStorage.RemoteEvents
- local Sold = RemoteEvents.ItemSold
- local Debounce = false
- script.Parent.Touched:Connect(function(hit)
- if hit.Parent:FindFirstChild("Humanoid") then
- local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
- if Player.PlayerStats.CurrentValue.Value > 0 then
- if Debounce == false then
- Debounce = true
- Sold:FireClient(Player, Player.PlayerStats.CurrentValue.Value)
- Player.PlayerStats.Coins.Value = Player.PlayerStats.Coins.Value + Player.PlayerStats.CurrentValue.Value
- Player.PlayerStats.CurrentValue.Value = 0
- wait()
- Debounce = false
- end
- end
- end
- end)
- ToolScript
- local tool = script.Parent
- local Settings = tool:WaitForChild("Settings")
- local Strength = Settings.Strength
- local Player = game.Players.localPlayer
- local PlayerUI = Player:WaitForChild("PlayerGui").PlayerUI
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local RemoteEvents = ReplicatedStorage:WaitForChild("RemoteEvents")
- local CoinClicked = RemoteEvents.CoinClicked
- local Debounce = false
- tool.Activated:Connect(function()
- if Player.PlayerStats.CurrentValue.Value > Player.PlayerStats.Storage.Value then
- if Debounce == false then
- Debounce = true
- CoinClicked:FireServer(Strength.Value)
- wait(0.25)
- Debounce = false
- end
- else
- if PlayerUI.StorageFull.Visible == false then
- if Debounce == false then
- Debounce = true
- PlayerUI.StorageFull.Visible = true
- wait(0.5)
- Debounce = false
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement