Don't know how to award badge to player while scripting event

Hello. I was attempting to script a event. I realized that I pretty much don’t even know how to award a badge on a remoteevent.
Properties:


LocalScript:

local eventmodel = script.Parent
local one = eventmodel.part1
local two = eventmodel.part2
local three = eventmodel.part3
local four = eventmodel.part4

local restoreproxy = eventmodel.restore.proximity.ProximityPrompt

restoreproxy.Enabled = false

one.ClickDetector.MouseClick:Connect(function()
	for _, part in pairs(one:GetChildren()) do
		if part:IsA("BasePart") then
			part.Transparency = 1
			part.CanCollide = false
		end
	end
	one.ClickDetector.MaxActivationDistance = 0
end)

two.ClickDetector.MouseClick:Connect(function()
	for _, part in pairs(two:GetChildren()) do
		if part:IsA("BasePart") then
			part.Transparency = 1
			part.CanCollide = false
		end
	end
	two.ClickDetector.MaxActivationDistance = 0
end)

three.ClickDetector.MouseClick:Connect(function()
	for _, part in pairs(three:GetChildren()) do
		if part:IsA("BasePart") then
			part.Transparency = 1
			part.CanCollide = false
		end
	end
	three.ClickDetector.MaxActivationDistance = 0
end)

four.ClickDetector.MouseClick:Connect(function()
	for _, part in pairs(four:GetChildren()) do
		if part:IsA("BasePart") then
			part.Transparency = 1
			part.CanCollide = false
		end
	end
	four.ClickDetector.MaxActivationDistance = 0
end)

local module1 = one.module

local module2 = two.module

local module3 = three.module

local module4 = four.module

if module1.Transparency == 1 and module2.Transparency == 1 and module3.Transparency == 1 and module4.Transparency == 1 then
	restoreproxy.Enabled = true
end

restoreproxy.Triggered:Connect(function()
	eventmodel.RemoteEvent:FireServer()
end)

Serverscript: (the handler basically)

local event = script.Parent

event.OnServerEvent:Connect(function()
	-- yea i gave up basically here
end)

when replicating from the client to the server, you can get the client (player) as the first argument in the OnServerEvent event

local event = script.Parent
local badgeservice = game:GetService("BadgeService")

event.OnServerEvent:Connect(function(player)
	if not badgeservice:UserHasBadgeAsync(player.UserId, 69696969) then -- second argument is the badge id
		badgeservice:AwardBadge(player.UserId, 69696969)
	end
end)

Thanks, but uhh…
The localscript doesn’t work, somehow.

because my freind local scripts only work in startergui, replicated storage and replicatedfirst, starterpack, and starterplayer

Ok, I put the localscript and the remote in the ReplicatedFirst.
It still doesn’t work…

do it in starterplayer instead.

dont forget to modify your code’s variables too.also put it in startergui or starterplayer smh

The localscript still does not work after putting in StarterPlayer.
And I also modified my variables.

any errors in the output? also did u put it in starterplayer or starterplayerscripts?

It worked when I shoved the scripts in the StarterPlayerScripts, but the ProximityPrompt is not showing when I collected the 4 items…

That’s something idk what ur talking about and not related to the post

This.
image

if module1.Transparency == 1 and module2.Transparency == 1 and module3.Transparency == 1 and module4.Transparency == 1 then
	game.Workspace.event.restore.proximity.ProximityPrompt.Enabled = true
end

It won’t enable.

Use :GetPropretyChangedSignal() event and detect their transparency if they are al transparent enable the proxy

You should put the event in ReplicatedStorage so it can be accessed by both the client and the server.

So… this?

module1:GetPropertyChangedSignal("Transparency"):Connect(function()
	if module2.Transparency == 1 and module3.Transparency == 1 and module4.Transparency == 1 then
		restoreproxy.Enabled = true
	end
end)

you would check all of them
so event inside event inside event and when they were all detected, you check their transparency

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