Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to change this local script into a normal script?

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

script.Parent.MouseButton1Click:connect(function()
	local p = game.Players.LocalPlayer
	local s = script.Parent.Sound
	s:Play()
	p.leaderstats.Bux.Value = p.leaderstats.Bux.Value + 1
	local o = game.ReplicatedStorage.One:clone()
	o.Parent = p.PlayerGui
	o.TextLabel:TweenPosition(UDim2.new(0.61, 0,0.661, 0), 'Out', 'Bounce', 1.5)
	wait(1)
	o:Destroy()
end)

1 answer

✓ Accepted answer

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

--[[Server Script]]--

local Event = Instance.new("RemoteEvent")
Event.Parent = game:GetService("ReplicatedStorage")
Event.Name = "TestEvent"

Event.OnServerEvent:Connect(function(player, bux) --player who fired, bux is cost of bux
	local stats = player.leaderstats
	stats.Bux.Value = stats.Bux.Value + bux
end)

and here is your fixed localscript

--[[ LocalScript ]]--

local Event = game:GetService("ReplicatedStorage").TestEvent

script.Parent.MouseButton1Click:connect(function()
    local p = game.Players.LocalPlayer
    local s = script.Parent.Sound
    s:Play()
    Event:FireServer(1) -- 1 is bux value what we firing to server
    local o = game:GetService("ReplicatedStorage"):WaitForChild("One"):Clone()
    o.Parent = p.PlayerGui
    o.TextLabel:TweenPosition(UDim2.new(0.61, 0,0.661, 0), 'Out', 'Bounce', 1.5)
    wait(1)
    o:Destroy()
end)


This discussion is preserved as it was. New answers, comments, and votes are closed.