Is this a good approach to interacting with stuff?

So I had an idea to make a sphere and weld it to the players character and then use overlap params to check when specific tagged models or parts are inside of the sphere I then use a proximity prompt to prompt the player to interact with it and then tell the server if we do interact with it, however, I’m starting to realize that having it on the client might not be the best approach. Is this fine or is it better to do it on the server?

character.ChildAdded:Connect(function(child)
	if CS:HasTag(child,"PlayerCollider") then
		local zone = Zone.new(child)

		for _,object in ipairs(workspace:GetDescendants()) do
			if CS:HasTag(object,"Interactable") then
				zone:trackItem(object)
			end
		end

		zone.itemEntered:Connect(function(item)
			local itemsArray = zone:getItems()
			local tags = CS:GetTags(item)

			--check if we're near fire (for sanity)
			for _,object in ipairs(itemsArray) do
				if CS:HasTag(object,"Fire") then
					PlayerModule:NearFire(true)
				end
			end

			--prompt to interact
			for _,tag in ipairs(tags) do
				if PromptModule[tag] then
					PromptModule[tag]()
					break
				end
			end
		end)

		zone.itemExited:Connect(function(item)
			if hrp:FindFirstChild("ProximityPrompt") then
				hrp:FindFirstChild("ProximityPrompt"):Destroy()
			end

			if CS:HasTag(item,"DebugFire") then
				PlayerModule:NearFire(false)
			end
		end)
	end
end)
1 Like