I don't know what to do with this script, it's really ruining my leaderboard values
01 | script.Parent.MouseButton 1 Click:connect( function () |
02 | local p = game.Players.LocalPlayer |
03 | local s = script.Parent.Sound |
04 | s:Play() |
05 | p.leaderstats.Bux.Value = p.leaderstats.Bux.Value + 1 |
06 | local o = game.ReplicatedStorage.One:clone() |
07 | o.Parent = p.PlayerGui |
08 | o.TextLabel:TweenPosition(UDim 2. new( 0.61 , 0 , 0.661 , 0 ), 'Out' , 'Bounce' , 1.5 ) |
09 | wait( 1 ) |
10 | o:Destroy() |
11 | end ) |
You need to use remote events. Insert script in serverscriptservice and type this...
01 | --[[Server Script]] -- |
02 |
03 | local Event = Instance.new( "RemoteEvent" ) |
04 | Event.Parent = game:GetService( "ReplicatedStorage" ) |
05 | Event.Name = "TestEvent" |
06 |
07 | Event.OnServerEvent:Connect( function (player, bux) --player who fired, bux is cost of bux |
08 | local stats = player.leaderstats |
09 | stats.Bux.Value = stats.Bux.Value + bux |
10 | end ) |
and here is your fixed localscript
01 | --[[ LocalScript ]] -- |
02 |
03 | local Event = game:GetService( "ReplicatedStorage" ).TestEvent |
04 |
05 | script.Parent.MouseButton 1 Click:connect( function () |
06 | local p = game.Players.LocalPlayer |
07 | local s = script.Parent.Sound |
08 | s:Play() |
09 | Event:FireServer( 1 ) -- 1 is bux value what we firing to server |
10 | local o = game:GetService( "ReplicatedStorage" ):WaitForChild( "One" ):Clone() |
11 | o.Parent = p.PlayerGui |
12 | o.TextLabel:TweenPosition(UDim 2. new( 0.61 , 0 , 0.661 , 0 ), 'Out' , 'Bounce' , 1.5 ) |
13 | wait( 1 ) |
14 | o:Destroy() |
15 | end ) |