How do i award a badge by clicking on a TextButtom

  1. What do you want to achieve? So im about to finish my game and i want to award the player a badge depending on what buttom they clicked on

  2. What is the issue? i uh, i dont know how to award it from the server


    im sorry if im stupid but im not that experienced with GetService or Remote Events

  3. What solutions have you tried so far? i tried looking on youtube and i found some info and methods such as fireServer and stuff, google nothing, the devforum i found a post saying to use a RemoteEvent and then executing it from the server

i tried using what i saw on youtube but didnt work

image
still the same message

im pretty sure i already did it with what i tried but i feel like im missing something, hope i explained myself correctly.

1 Like

my response might be extremely stupid, but try testing this in actual roblox instead of studios

it would be the same since its the same testing it in studio and in roblox, it just doesnt register the badge in the studio

I mean, it says it can only be awarded by roblox game servers, and testing on studio uses a local server, so I suspect that could be the problem

just try it, it does no harm even if it doesn’t work

You almost had it :frowning_with_open_mouth: In your LocalScript you fired the RemoteEvent, but from what I saw it doesn’t seem like you actually connected the Event to detect the calls from

Honestly though, RemoteEvents are simple once you get to know them well as they’re capable of handling 1-way transportation

Think of it like this here:

We have 3 things:

  • Point A
  • Point B
  • Main Truck

Point A is where we currently are now, and nothing can’t happen unless we call our FireServer() function as you stated before

Once we start going, we then travel onto Point B where we’ll receive those said “calls” to transport the goods over, but we need to have something called OnServerEvent for Point B in specific so we can confirm when those Events fire and to receive back :eyes:

Although, you put your RemoteEvent within ServerScriptService & unfortunately, that’s only Server-Sided so the client isn’t able to see that RemoteEvent

image

If you put it somewhere that’s replicated easily, like ReplicatedStorage then that can work just fine :+1:

Now we’re still in Point A, but now we have to arrive to Point B in order to receive it, so we can do something like this here:

local RS = game:GetService("ReplicatedStorage")
local BadgeService = game:GetService("BadgeService")
local PacifistBadge = 4254040307

local Event = RS:WaitForChild("PacifistEnding") -- We want to use this

Event.OnServerEvent:Connect(function(Player) -- By default, OnServerEvent passes the Player as the first parameter
    BadgeService:AwardBadge(Player.UserId, PacifistBadge)
end)

You’ll also have to change your LocalScript as well so that it can detect the RemoteEvent inside ReplicatedStorage but that should be everything!

This actually Isn’t true since the true published client would be the Roblox loaded game itself

hello there!, hey i tried what you told me and it worked :smiley: , but uh theres a little problem, the badge isnt showing up, theres no errors in the output, everything works but when i click on the buttom the badge doesnt show up and doesnt appear in my inventory either, i changed OnServerEvent to OnClientEvent, i forgot to say my game is meant to be single player so i changed it to that, i dont OnClientEvent is causing the problem tho, but i feel like once again im missing something, btw thanks for the help, but do you know about this?

When you’re calling FireServer(), are you doing this on a LocalScript? Cause RemoteEvents can only transport data over from 1 area, to another different area

You can try and add some print statements as well (print("Test Message")) to debug the issue further, as you should have the LocalScript that calls FireServer(), and a ServerScript that receives it via .OnServerEvent

you need da remote event!!!

dddddddddddddddddd

wait wait, how can i make ServerScriptService receive it via OnServerEvent? i dont get it, im not asking for the script but like can you explain it once again, sorry i still quite dont catch it, and yes im calling fireserver from a local script

Unfortunately, ServerScriptService has something that’s called “NOT REPLICATED”, as in you’re unable to access it from 1 side, while you can on another and vice versa

Examples being:

  • Attempting to index ServerStorage on a LocalScript
  • Finding a folder inside ServerScriptService

image

The client and the server are both, two different things individually

you need to set the Player variable as i don’t see a Player variable, also, in a server script you cannot use game.Players.LocalPlayer as it’s not a LOCAL script, so you would have to do script.Parent.Parent.Parent… and so on until you get to the player.

heres a script, create a remote event with the name of badgeevent or something else

local button = script.Parent
local event = game.ReplicatedStorage.BadgeEvent -- example, just use a remoteevent

button.MouseButton1Click:Connect(function()
   event:FireServer()
end)

our script in serverscriptservice:

local event = game.ReplicatedStorage.BadgeEvent -- the same thing as last time

event.OnServerEvent:Connect(function(player) -- remember to put player
   game:GetService("BadgeService"):AwardBadge(player.UserId, 4254040307)
end)

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