Trying to make a highlight npc gamepass

so would it look like this?

Yes, but make sure to adjust it to your needs, as what I just showed was a general example of how to use it.

(Also, my mistake, add a parenthesis after “MarketplaceService”, I forgot to add that.)

its not working but would that be because of the highlighted errors in the code (haspass, player, gamepassid end and local)

could it also be to do with this code?

still cant find the solution, any ideas?

Try replacing your server script with this.

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService("MarketplaceService")

checkGamepassEvent = ReplicatedStorage:WaitForChild("CheckGamepassEvent")

local gamepassId = 870314415

checkGamepassEvent.OnServerInvoke = function(player)
	return MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamepassId)
end

(Make sure checkGamepassEvent is a RemoteFunction!)

sorry what do you mean by remote function? (im still learning lua btw) is that the same as a remote event? also could the problem be to do with my npc?

A RemoteFunction is slightly different from a RemoteEvent. Basically, a RemoteFunction is a way to communicate across client-side boundaries, whereas a RemoteEvent can only transfer information, without receiving a result in return. More information here if it helps: RemoteFunction | Documentation - Roblox Creator Hub

From what I see, you’re npcs should be fine, only because of the little information I have currently.

thank you for explaining, and if you would like any information of the scripts or npc or anything let me know

It would be helpful if you sent a picture of your npc folder with your npcs in explorer, just to confirm it matches with your code.

Also, did the piece of code I sent you work on post #11? Just curious, sorry if I sound impatient.

sorry iT didnt work im not sure why but heres the images if this is what you mean
image
image

image

image

1 Like

It seems like checkGamepassEvent is still a RemoteEvent. Try changing it to a RemoteFunction, then try again.

sorry i clicked event instead of function but its somewhat worked when i changed it! it now looks like this
image
which is different as before apsolutely nothing happened

i hcanged the line thickness


and the colour but its not letting me see it through walls

image
second part to it? not sure why

Instead of selection boxes, try using highlights. This way, you can see it through walls.

local function highlightNPCs()
	local npcsFolder = game.Workspace:FindFirstChild("NPCs")
	
	if npcsFolder then
		for _, npc in pairs(npcsFolder:GetChildren()) do
			if npc:IsA("Model") then
				local highlight = Instance.new("Highlight")
				highlight.Parent = npc
				
				highlight.FillColor = Color3.fromRGB(255, 0, 0)
				highlight.OutlineColor = Color3.fromRGB(255, 0, 0)
				
				highlight.FillTransparency = 0.5
				highlight.OutlineTransparency = 0
			end
		end
	else
		warn("No NPCs folder found in Workspace")
	end
end
1 Like

it works!! thank you so much for your help you have been brilliant!
i have made sure it works only with the gamepass and it works

image

thank you!

1 Like

You’re welcome! Glad I could help, good luck on your project :wink: !

1 Like