You're right about having to make this compatible with Filtering Enabled. Changes to the client or objects inside the client will not be replicated to the server, unless of course the server makes the change. To fix this, we'll handle the MouseButton1Click event on the client and the actual changing of values on the server.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = Instance.new("RemoteEvent")
Remote.Parent = ReplicatedStorage
Remote.OnServerEvent:Connect(function(player,check)
if check == "Rebirth" and player.leaderstats.Cash.Value >= 10000 then
player.leaderstats.Cash.Value = 150
player.leaderstats.Rebirths.Value = player.leaderstats.Rebirths.Value + 1
end
end)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = ReplicatedStorage:WaitForChild("RemoteEvent")
local button = script.Parent
button.MouseButton1Click:Connect(function()
Remote:FireServer("Rebirth")
end)
If you have any questions, feel free to leave them in the comments.
##Resources:
Remote Events
##Accept and upvote if this helps!
1 comment
accept my answer since u said it helped