Help with Scripting Problem

Currently I am scripting a rebirth system for my obby which I ended up figuring out via remote functions. The way I have it working, for reference, is that you walk over a part, a gui pops up with a button asking to rebirth. There’s a local script that fires to a server script in serverscriptservice via a remote function when the button is touched, checking to see if they meet the criteria. I have a different one for each section. The problem I am running into is in terms of what happens if the person doesn’t meet the criteria. I put a text that will be visible saying " You don’t have the right stages to rebirth" etc- if they don’t have the right amount of stages but the way I was scripting it didn’t seem to work. I think maybe because I was trying to do it via a server script instead of a local script. The question I have is: Do I need to make another remote function or remote event to make the text section visible or is there another way to do it? Apologies if this is somewhat a mouthful to read. I am not sure how else to word it.

If you need any scripts or any further information, please let me know!

yeah, so, when you send a remote event to the server, you can first pass the player over and other parameters, this will enable you to access the gui for the player if im not mistaken, then you can change the text from the server by creating a listener, saying hey when this is called, check if the player doesnt meet the critera, then say error message, if they do, then rebirth and however you need that done, although you could use fireclient if you so wanted, but i dont think its necessary for putting text on screen if im understanding correctly

1 Like

I have the script set up checking if they meet the criteria but when trying to do an else statement to make a TextLabel visible, it doesn’t seem to work. Let me include what I have:

local player = game.Players.LocalPlayer
local rebirthButton = script.Parent.RebirthButton
local replicatedStorage = game:WaitForChild("ReplicatedStorage")

rebirthButton.MouseButton1Click:Connect(function()
	replicatedStorage.Rebirth:InvokeServer()
end)

^This is in my gui as a local script.

game.ReplicatedStorage.Rebirth.OnServerInvoke = function(player)
	if player.leaderstats.Stage.Value >= 26 then
		player.leaderstats.Rebirths.Value += 1
		player.leaderstats.Stage.Value = 1

		player:LoadCharacter()
	end
end

^This is a portion of my script in ServerScriptService that enacts the function. I was trying to do something like this:

game.ReplicatedStorage.Rebirth.OnServerInvoke = function(player)
	if player.leaderstats.Stage.Value >= 26 then
		player.leaderstats.Rebirths.Value += 1
		player.leaderstats.Stage.Value = 1

		player:LoadCharacter()
else
game.StarterGui.RebirthGui.RebirthFrame.Warning.Visible = true
wait(5)
game.StarterGui.RebirthGui.RebirthFrame.Warning.Visible = false
        end
	end
end

But it didn’t seem to work. But that is the gist of what I am trying to do.

did you pass the player through the button click

Rebirth:InvokeServer(player)

maybe thats why its not working? and setting the player gui stuff through the parameter so like player.startergui.textbutton yada yada whatever it may be, i cant see heirarchy given im on mobile atm, instead of the game.StarterGui or else i think thatd set it visible for everyone if im not mistaken

1 Like

Oh, you’re right. Let me try doing that instead of the game thing.

Edit: you’re literally a genius lol. That was the reason it wasn’t working! I needed to do player.playergui etc for it to work omg. Thank you!

awesome! glad it worked, good luck!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.