Answered by
4 years ago Edited 4 years ago
First off, use RemoteEvents since the FilteringEnabled update came around to stop exploiters.
When using a RemoteEvent it would be like this, put the Sword in ServerStorage, and make a remote in ReplicatedStorage named "BuySword"
Localscript
01 | local player = game.Players.Localplayer |
03 | script.Parent.MouseButton 1 Click:connect( function () |
05 | game.ReplicatedStorage.BuySword:FireServer() |
07 | if player.leaderstats.Time.Value > = 120 then |
09 | script.Parent.BackgroundColor 3 = Color 3 ( 0 , 255 , 0 ) |
11 | script.Parent.BackgroundColor 3 = Color 3 ( 255 , 255 , 255 ) |
15 | script.Parent.BackgroundColor 3 = Color 3 ( 255 , 0 , 0 ) |
17 | script.Parent.BackgroundColor 3 = Color 3 ( 255 , 255 , 255 ) |
Serverscript
03 | game.Players.PlayerAdded:Connect( function (player) |
05 | local stats = Instance.new( "Folder" , player) |
06 | stats.Name = "leaderstats" |
08 | local Time = Instance.new( "NumberValue" , stats) |
13 | game.ReplicatedStorage.BuySword.OnServerEvent:Connect( function (player) |
15 | if player.leaderstats.Time.Value > = cost then |
17 | game.Serverstorage.Sword 1 :Clone().Parent = player.Backpack |