You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? I want help find a solution to my prolem
What is the issue? when at a certain point in time i want a gui button to show up client side. i use fireclients(p,“Button”,Text ← “Table”).
When that button is pressed i want it to send a signal to the server (fireserver) to i can add to a number value by one each time the button is pressed.
The issue with this is. the first time you press the button it works and adds to the number value once by one. But if you press the button more than once. the time the remotevent fires will progress down the numberline. e.g press button once = fireserver once , press button once again = fireserver twice , press the button once again after that = fireserver thrice and so on.
What solutions have you tried so far? i’ve many solutions but none of them seem to work.
—More Detail----
Ok, so let me make it more clear. Server Function
—The Server is trying to make ask multiple choice questions to player’s. the questions and answers are in a table.
— Now this part it key. There is a number value(an index if you’d like). this number choose what question in the table is chosen. e.g local index = 1 local currentquestion = question[index]
— So we then invokeclient and send through the questions. so the client can display then .
— This function as has a remote.onserverevent:connect(function() in it. so it can listen for the response of the client.
— when the client responds. the remote event. has a function that it calls to check the answer. (if it’s right or not). the function also calls the previous function so it can change the question
— when we want to change the question we add 1 to the number value.
. Ok so the issue is when the client fires the server a second time. by using an input method once. e.g (pressing a button. or using chatted). it will add the number twice.
I’m unsure what your asking. One interpretation is that you’re creating a map voting system and you want players to only have one vote, but when they click it again they can get more. The second interpretation is that when you click it the first time it goes up by 1, then 2, so on the second click the total would be 3 when it should be 2?
It would be nice if you could show us your code and also explain the problem in a more understandable way.
Basically. The player is being asked a multiple choice question. the server controls when the questions are asked and sorts which question are to be asked to the player.(the current question is controlled by a number Variable. once the player has answered. we add 1 to the number variable. so we can moved ahead in the table of questions and change the current question) once the questions have been sorted. it then send a signal to the server to display the question and the answers that go with it. now when the player picks one of the answers. it signals the server to check the answer . once the answer has been checked. It addeds to the number variable. this number variable controls which question should be chose in the table e.g (question[2], all the questions are in a table btw). now in a perfect world were all my scripting ideas work with no bugs. that should’ve worked. but instead the remote event fired by the client wants to fire twice. here’s my code—
self. CurrentQuestoin = self.Questions[self. currentindex]
for _,v in pairs(self.Players) do
local jean = client:InvokeClient(game.Players[v.Name],"SayAnswer",
{self.CurrentQuestoin} ) --- this displays the questions and answers---
end
local jen = GameRemote.OnServerEvent:Connect(function(plr,l,data)
if l == "CheckAnswer" then
self:CheckAnswer(plr,data) --- This checks the answer the player sent from the server. in that function aswell. it calls this current function (playgame()) too so it change the question once answered
return
end
end)
end
if you’re wondering why i’ve used one remotefunction as well and not just a remote event. well let me tell you a very jarring thing about remotefunctions. they like to return values when they want to. so if i wanted it to be like. The moment you press this button return something. it will return without the event happening!. so yeah. im using the remotefunction to display and the remoteevent to send the player’s answer ,ok.
one of my other solutions was change the button input. For player chatted input. but that didnt work. but the code im about to send is that failed solution
–Client–
if l == "SayAnswer" then
pressed = false
script.Parent.Dialog.Visible = false
local qgui = script.Parent.SurfaceGui.Question
qgui.Visible = true
qgui.Text = Data[1][1]
for o, v in pairs(qgui:GetChildren()) do
v.Text = Data[1][2][tonumber(v.Name)]
end
end
UIS.InputEnded:connect(function(UIS,gameProcessedEvent) --- **This whole thing here just it so the player has to press space before answering** ---
if gameProcessedEvent then return end
if UIS.KeyCode == Enum.KeyCode.Space then
if l == "SayAnswer" then
pressed = true
end
end
end)
plaer.Chatted:connect(function(msg)
if pressed == true then
finalRemote:FireServer("CheckAnswer",msg) --- **sends the player's answer to the server** ---
end
end)
Yeah, i havent tested with other people. that’s why the loop that sends the questions and answers to each player involved isnt wrapped in a spawn or coroutine yet
You must include string filtering, players can say anything and they can say inappropriate words, which other players will see. You can solve this, by using this: TextService | Documentation - Roblox Creator HubFilterStringAsync. If it’s not added, Roblox will moderate your game, and maybe account for allowing people to say anything and other people would able to see it. Here is also example how to use it: Text Filtering | Documentation - Roblox Creator Hub.
Back to your question, I don’t understand what your trying to do.
Ok, so let me make it more clear. Server Function
—The Server is trying to make ask multiple choice questions to player’s. the questions and answers are in a table.
— Now this part it key. There is a number value(an index if you’d like). this number choose what question in the table is chosen. e.g local index = 1 local currentquestion = question[index]
— So we then invokeclient and send through the questions. so the client can display then .
— This function as has a remote.onserverevent:connect(function() in it. so it can listen for the response of the client.
— when the client responds. the remote event. has a function that it calls to check the answer. (if it’s right or not). the function also calls the previous function so it can change the question
— when we want to change the question we add 1 to the number value.
. Ok so the issue is when the client fires the server a second time. by using an input method once. e.g (pressing a button. or using chatted). it will add the number twice.