Sorry bud but you really need a LocalScript in order for the button to work. To make your data store work, you can use a RemoteEvent to change the value in server and a RemoteFunction to get the value of the player from the server (because if you get it to the client it might not be the same to the server since hackers can change anything ONLY to the client).
First, you create a RemoteEvent and a RemoteFunction inside ReplicatedStorage. Name the RemoteEvent SetValue and the RemoteFunction GetValue.
Next, you will create a script in ServerScriptService and name it RemoteHandler.
Then, you will create a listener for SetValue and a callback function for GetValue in RemoteHandler.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GetValue = ReplicatedStorage.GetValue
local SetValue = ReplicatedStorage.SetValue
GetValue.OnServerInvoke = function(player, valueName)
local leaderstats = player:FindFirstChild("Leaderstats")
if leaderstats then
local value = leaderstats:FindFirstChild(valueName)
if value then
if value:IsA("ValueBase") then
return value.Value
end
end
end
end
SetValue.OnServerEvent:Connect(function(player, valueName, valueSet)
local leaderstats = player:FindFirstChild("Leaderstats")
if leaderstats then
local value = leaderstats:FindFirstChild(valueName)
if value then
if value:IsA("ValueBase") then
value.Value = valueSet
end
end
end
end)
Lastly, you can use them in the LocalScript and it should look like this:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GetValue = ReplicatedStorage:WaitForChild("GetValue")
local SetValue = ReplicatedStorage:WaitForChild("SetValue")
function Convert()
if GetValue:InvokeServer("Convert") > GetValue:InvokeServer("Robux") then
script.Parent.Parent.ConvertBox.Text = "Invalid conversion amount!"
task.wait(2)
script.Parent.Parent.ConvertBox.Text = ""
else
SetValue:FireServer("Tix", (GetValue:InvokeServer("Tix") - GetValue:InvokeServer("Convert")))
SetValue:FireServer("Robux", (GetValue:InvokeServer("Robux") + GetValue:InvokeServer("FinalConvert")))
end
end
script.Parent.MouseButton1Click:Connect(Convert)