Rebirth script not working

Hey! So I been having trouble on my rebirth system, bassically when I click the rebirth button it doesn’t work.

I tried a lot of things such as looking into dev console which has no errors, redid the script, even tried to do it on another button, but still doesn’t work.

Script

local plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function()
	if plr.leaderstats.Rebirths.Value == 0 and plr.leaderstats.Steps.Value >= 10000 then
		workspace.Events.Rebirth:FireServer()
	else
		if plr.leaderstats.Rebirths.Value >= 1 and plr.leaderstats.Steps.Value >= (plr.leaderstats.Rebirths.Value * 10000) + 10000 then
			workspace.Events.Rebirth:FireServer()
		end
	end
end)

Can anyone tell me what the problem is?

You must give it time, try with:WaitForChild()

To start you should create a function then connect the click event from a click detector to fire the function, can you show the serverscript of the onserverevent, also I realized you’re not passing any information tot he server for the rebirth for starters do please as the first parameter

What type of script are you using?

If your using a local script, you cant access Workspace with it since it can only see client wise. You’ll need to put the remote events into ReplicatedStorage so both the server and client can see it. And why are you firing an event?

I did but it still doesn’t work.

Try adding a print statement to see where the problem is.

Im using a local script, and im firing a event just because for my anti cheat system

Doesn’t print the thing so yeah.

Alright, so I had this similar problem yesterday. It didn’t register the mouse click. Try using .MouseButton1Down instead.
Edit:
Also change :connect() to :Connect()
Edit 2:
Also I realized, since local scripts don’t work in workspace, maybe they don’t see events in there too?

1 Like

Move the events into ReplicatedStorage and change the variables so it looks at ReplicatedStorage and get the events. That way, it can see the events. LocalScripts cant see anything related to the server, that means it probably wont be able to find anything in workspace.

In a local script try

local player = game.Players.LocalPlayer
local ClickDetector = game.Workspace:WaitForChild("ClickDetectorName")
local event = game.ReplicatedStorage.RemoteEvent -- change whatever the name of the remote event is

local function Rebirth()
   if plr.leaderstats.Rebirths.Value == 0 and plr.leaderstats.Steps.Value >= 10000 then
event:FireServer()
end)


ClickDetector.MouseClick:Connect(Rebirth)

Oh yeah forgot to make connect to Connect

You can add and change whatever but this is the basic idea of it

The client can see everything in workspace.

2 Likes

didn’t work for me idk why tho

Did you try mine? If so please let me know how it went

ok wait up let me try, also isn’t that for a part?

Aren’t you clicking a part or a gui?

I’m clicking a gui button not a part lol

Oh then do Button.MouseButton1Down:Connect(Rebirth)