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

Content expected, got nil error. Help?

So, I'm following a tutorial on how to make a Find The game, and I was doing the GUI for the "Nice! You found whatever!" thingy.

But when I try collecting the thing I made to see if the GUI works, I get this error instead. "Unable to assign property value Image. Content expected, got nil."

Here's the code block for activating the GUI when you obtain the thing in the Find The game.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvents = ReplicatedStorage:WaitForChild("RemoteEvents")
local NewlyCollected = RemoteEvents:WaitForChild("NewlyCollected")

local frame = script.Parent
local CWName = frame:WaitForChild("CWName")
local CWImage = frame:WaitForChild("CWImage")

NewlyCollected.OnClientEvent:Connect(function(name,imageId)
	CWName.Text = name.." Wing!"
	CWImage.Image = imageId
end)

3 comments

0

Show us the script for firing the RemoteEvent

0

Check answer:

0

Nevermind, figured it out. I forgot the imageId in the NewlyCollected:FireClient thing

2 answers

So, here's the script firing to the RemoteEvent to obtaining one of the badges if that's what you're looking for.

local BadgeService = game:GetService("BadgeService")
local cosmicwing = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvents = ReplicatedStorage:WaitForChild("RemoteEvents")
local CollectBadge = RemoteEvents:WaitForChild("CollectBadge")
local NewlyCollected = RemoteEvents:WaitForChild("NewlyCollected")

local name = "Cosmic"
local imageId = "rbxassetid://10172884919"

function debounce(func)
	local isRunning = false
	return function(hit)
		if not isRunning then
			isRunning = true
			func(hit)
			wait(5)
			isRunning = false
		end
	end
end


local function giveBadge(player, badgeid)
	local success, badgeInfo = pcall(function()
		return BadgeService:GetBadgeInfoAsync(badgeid)
	end)
	if success then
		if badgeInfo.IsEnabled then
			local success, result = pcall(function()
				NewlyCollected:FireClient(player,name)
				return BadgeService:AwardBadge(player.UserId, badgeid)
			end)
			if not result then
				CollectBadge:FireClient(player)
			end
		end
	end
end

cosmicwing.Touched:Connect(debounce(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local character = hit.Parent
		local player = game.Players:GetPlayerFromCharacter(character)
		if player then
			giveBadge(player, 2127270172)
		end
	end
end))

1 comment

0

@MattVSNNL

hey you! have you ever heard of enes? if you are in trouble, better call enes!

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