Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to change this local script into a normal script?

Asked by 6 years ago

I don't know what to do with this script, it's really ruining my leaderboard values

01script.Parent.MouseButton1Click: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(UDim2.new(0.61, 0,0.661, 0), 'Out', 'Bounce', 1.5)
09    wait(1)
10    o:Destroy()
11end)

1 answer

Log in to vote
1
Answered by
HaveASip 494 Moderation Voter
6 years ago
Edited 6 years ago

You need to use remote events. Insert script in serverscriptservice and type this...

01--[[Server Script]]--
02 
03local Event = Instance.new("RemoteEvent")
04Event.Parent = game:GetService("ReplicatedStorage")
05Event.Name = "TestEvent"
06 
07Event.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
10end)

and here is your fixed localscript

01--[[ LocalScript ]]--
02 
03local Event = game:GetService("ReplicatedStorage").TestEvent
04 
05script.Parent.MouseButton1Click: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(UDim2.new(0.61, 0,0.661, 0), 'Out', 'Bounce', 1.5)
13    wait(1)
14    o:Destroy()
15end)
Ad

Answer this question