Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Either My Client Is Not Firing Or Not Detecting Its Been Fired?

Basically, I'm trying to make an Application Center that automatically ranks the player. I have all of the gui scripts finished, and it fires the client, but for some reason its not working. I've tried to figure out the problem, but I cant. I know the problem is coming from the RemoveEvent not firing, and the Server script is fine.

LocalScript That Ranks Player:

local HttpService = game:GetService("HttpService")

local Server = require(script.Server)


local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RankPlayer = game.ReplicatedStorage.RankPlayer








RankPlayer.OnClientEvent:Connect(function()

Server.SetRank(5947903, game.Players.LocalPlayer.UserId, 3)

end)

Ending Script To Fire Client:

while true do
	if script.Parent.Parent.Right.Value < 8 then
		script.Parent.Text = "Sorry, you did not pass. Please review the questions you got wrong and try again."
	elseif script.Parent.Parent.Right.Value >= 8 then
		script.Parent.Text = "Congratulations, you passed! You have been ranked: [LR] Officer."
		game.ReplicatedStorage.RankPlayer:FireAllClients()
	end
	wait()
end


Scirpt that changes Selected Value:


 script.Parent.MouseButton1Click:Connect(function()
	local current = script.Parent.Parent.Selected.Value
	if current == "None" then
		script.Parent.Text = "X"
		script.Parent.Parent.Selected.Value = "A"
	elseif current == "A" then
		local switch = current.."B"
		script.Parent.Parent:FindFirstChild(switch).Text = ""
		script.Parent.Text = "X"
		script.Parent.Parent.Selected.Value = "A"
	
	
	end
end)


Determines If Right Or Wrong

script.Parent.Parent.Parent.Submit.END.MouseButton1Click:Connect(function()
	local q = script.Parent.Parent.Parent.Q1.Selected.Value
	local a = script.Parent.Parent.Parent.Q1.Right.Value
	if a == q then
		script.Parent.Text =  " ?"
		script.Parent.Parent.Right.Value = script.Parent.Parent.Right.Value + 1
	else
		script.Parent.Text = "X"
	end
end)

If you can help me, thank you so much! This problem has been so annoying, and I've tried fixing it for about a week now with no success.

2 comments

0

Did u fireserver from client?

0

Do ReplicatedStorage:FireServer() on the local script

2 answers

sometimes the function does not load immediatly

try a anonymous function

local HttpService = game:GetService("HttpService")

local Server = require(script.Server)
	 

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RankPlayer = game.ReplicatedStorage.RankPlayer






	 

RankPlayer.OnClientEvent:Connect(function()

Server.SetRank(5947903, player.UserId, 3)

end)

4 comments

0

If I do that, then I cannot reference the player's UserId

0

o ok

0

Could I do Server.SetRank(5947903, game.Players.LocalPlayer.UserId, 3) ?

0

Just tried it, still didn't work

One of the main issues I see regarding this is the fact that the FireClient() method is empty.

In order to use FireClient(), one needs to have the player in the first parameter of the method, since you don't know which client you're trying to send the message to. If one needs to fire to all the clients, then one can simply do FireAllClients() to trigger the event for every single client.

19 comments

0

I would try and further help by stating which variable you would need to put in FireClient, but in the scripts you've provided, it seems like there's not enough information present for me to determine this.

0

I hope this answer does assist you in attaining a solution however.

0

Hmm, what else would you need?

0

I'd need to know how you get the player which triggers the change in the value, as that's the only way to determine which player to fire to.

0

Uhh I dont think I do

0

Hmm, could you please explain the process behind how the script is supposed to work, I might be able to find out how you can detect the player.

0

Basically, the GUI I made changes a String Variables value, and at the end, it looks to see if the string values are above 8, and if it is, it fires the client. (Thats In a LocalScript) Then, in another script, when the client is fired, it uses the SetRank function inside of my Server Script, I can edit the post to show the server script if you would like.

0

I see you've edited it to include the SetRank script. My bigger question is this, in the while loop, what is script.Parent.Parent, and more importantly, is this a local script or server script?

0

OnClientEvent doesn't have a Player parameter either. You should use game.Players.LocalPlayer in your LocalScript instead

0

Script.Parent.Parent.Right is a String Value, and it changes for each question right, it's +1. Thats also in a LocalScript

0

I just edited all scripts to match up with what I have currently from you guys' suggestions

0

Well, if it's a string value, then wouldn't you need to run tonumber() on it to convert it into a number for comparisons?

0

My bad, it's a number value. Im going to go in and test if its changing or not

0

Hmm it seems its not changing

0

You'll need to post something regarding where the values are being changed then.

0

Ok I added it

0

Uh, the code ya posted doesn't show Right changing, that or I'm assuming it changed to X???

0

Uh, the code ya posted doesn't show Right changing, that or I'm assuming it changed to X???

0

Its supposed to be changing Selected, and then ill add some more code to show when it determines if correct or not.

This discussion is preserved as it was. New answers, comments, and votes are closed.