local player = game.Players.LocalPlayer local clicks = player:WaitForChild("leaderstats"):WaitForChild("Clicks") local rebirths = player:WaitForChild("leaderstats"):WaitForChild("Rebirths")
script.Parent.MouseButton1Click:Connect(function() if clicks.Value >= 100 then script.Parent.Text = "Success!" rebirths.Value = rebirths.Value +5 clicks.Value = 0
end if clicks.Value < 100 then script.Parent.Text = "Not Enough Clicks" wait(2 script.Parent.Text = "5 Rebirths - 100 Clicks" end
end)
There are multiple things wrong, First of all you shouldn't make this a script or a local one, What you should do is the following:
Make a Remote Event to rebirth the player, Give the Remote Event a OnServerEvent function:
(note: If you want to just copy this straight up make sure to name the remote event "RebirthEvent" and put it inside the text button with the script and the local script that fires it)
script.Parent.RebirthEvent.OnServerEvent:Connect(function() local player = script.Parent.Parent.Parent.Parent local rebirths = player:WaitForChild("leaderstats"):WaitForChild("Rebirths") local clicks = player:WaitForChild("leaderstats"):WaitForChild("Clicks") if clicks.Value >= 100 then script.Parent.Text = "Success!" rebirths.Value = rebirths.Value + 5 clicks.Value = 0 end if clicks.Value < 100 then script.Parent.Text = "Not Enough Clicks" wait(2) script.Parent.Text = "5 Rebirths - 100 Clicks" end end)
Local script to fire the RemoteEvent:
script.Parent.MouseButton1Click:Connect(function() script.Parent.RebirthEvent:FireServer() end)
If this helped make sure to mark this answer as solution!