#MouseButton1Click doesn't work
94 messages · Page 1 of 1 (latest)
if it doesnt fix
nope
Tell me an exact location for the script
like game.ScreenGui.example
just fix it
if it doesnt work
doesnt work at all
look
using remoteevent?
ok
i read
cant lisen dont have tts
warn("ScreenGui or BadgeAwardButton not found.")
popped up
wth
Please, help?
local click = game.Players.LocalPlayer.PlayerGui:FindFirstChild('2D')
local click2 = click.MainFrame.Buttons:WaitForChild('Play')
local BadgeService = game:GetService("BadgeService")
local Players = game:GetService("Players")
--[ LOCALS ]--
local PlayedBadge = 2146323716
--[[ UI FUNCTION ]]--
local function AddUI(pl)
local PlayerGui = pl:WaitForChild("PlayerGui")
local Frame = game.StarterGui.FirstTimePlayingGui:Clone()
Frame.Parent = PlayerGui
Frame.Enabled = true
end
local function addBage9(player)
local success, badgeInfo = pcall(BadgeService.GetBadgeInfoAsync, BadgeService, PlayedBadge)
if success then
if badgeInfo.IsEnabled then
if not BadgeService:UserHasBadgeAsync(player.UserId,PlayedBadge) then
AddUI(player)
BadgeService:AwardBadge(player.UserId,PlayedBadge)
else
print("player owns badge")
end
else
print("badge is disabled")
end
else
print("error getting badge info")
end
end
--[ FUNCTIONS ]--
click2.MouseButton1Click:Connect(function()
addBage9(game.Players.LocalPlayer)
end)
lifesaver
StarterGui.FirstTimePlaying:5: attempt to index nil with 'PlayerGui' error pops up at first line
@analog panther
Sorry for ping
The names are correct or do I need to edit something?
Because it doesn't work
send script again
game.Players.LocalPlayer
Add this to the addBage9 parenthesis at the mousebutton1clickfunction.
To double check the script and the gui are inside game.StarterGui
This is the script I am using curently
alright nvm then
Added it.
😭
Click on localscript -> remote event to serverscript -> serverscript gives badge
Yes, you should make sure that the script and the GUI are inside game.StarterGui. However, you should also note that the script will not run in game.StarterGui because it is a server script and StarterGui is a client-only service. You should move the script to ServerScriptService or another server-side location. Alternatively, you can make the script a local script and keep it in StarterGui, but then you will need to use a remote event to communicate with the server and award the badge.
I am not at all familiar with remote events can you like add it?
To use the remote event, you need to create one in a shared location, such as ReplicatedStorage. Then, you need to write two scripts: one for the sender and one for the receiver. The sender script will call the FireServer method on the remote event, passing any arguments you want to send. The receiver script will connect a function to the OnServerEvent property of the remote event, which will run whenever the event is fired. The function will receive the arguments sent by the sender, as well as the player who fired the event.
Create a remote event named "AwardBadge" in ReplicatedStorage
Local Script in starterplayerscripts.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BadgeService = game:GetService("BadgeService")
local Players = game:GetService("Players")
local AwardBadge = ReplicatedStorage:WaitForChild("AwardBadge")
local PlayedBadge = 2146323716
local function checkBadge()
local player = Players.LocalPlayer
if not BadgeService:UserHasBadgeAsync(player.UserId, PlayedBadge) then
AwardBadge:FireServer(PlayedBadge)
end
end
checkBadge()
Server script in serverscriptservice
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BadgeService = game:GetService("BadgeService")
local AwardBadge = ReplicatedStorage:WaitForChild("AwardBadge")
local function awardBadge(player, badgeId)
if BadgeService:GetBadgeInfoAsync(badgeId).IsEnabled then
BadgeService:AwardBadge(player.UserId, badgeId)
end
end
AwardBadge.OnServerEvent:Connect(awardBadge)
This is an example though, so you will need to implement it in your system, yourself.
yes
Fires from the localscript, green box, to the serverscript, greenbox
I would do all checks on serverside
It is more safe, I know
Yes
Yo, come help if so smart
i didnt said i was smart
💀
but damn
either this rly difficult
or yall not smart
i said send code and u ignored me
I personally do almost everything on the server.
I just got into the situation bruv.
And connect everything with RemoteEvents?
what are you trying to connect
client to the server obviously
with whose help?
lets gooo
Just gotta use RemoteEvents
lol
@analog panther If still available, can you help me with an older issue?
If yes check this https://discord.com/channels/448986884497211392/1112999356921036851
This spans along 2 threads
First thread was a guy being just dumb and not helping me
How do I make it that when a player presses L after 15 seconds their health and max health increases by 900000 and their max health and health decreases by 969 every second and this lasts until the player dies, make a modern script.