Why is the script not detecting the remote function?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want to know how to fix this error, it’s so annoying and it’s breaking my game.

  1. What is the issue? Include screenshots / videos if possible!

why is the server not detecting the remote function?

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I tried adding a wait, but it doesn’t work, I checked the name and everything.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

image

local mps = game:GetService("MarketplaceService")
local DataStore = game:GetService("DataStoreService")
local PlayerData = DataStore:GetDataStore("Data_1")

local function LoadData(plr,Money,Coins,ItemEquipped)
	local Data = PlayerData:GetAsync(plr.UserId)
	if Data then
		Money.Value = 0
		Coins.Value = Data.Stats.Coins
		ItemEquipped.Value = tostring(Data.Stats.Item)
		for _,ItemStored in pairs(Data.Items)do
			if not plr.Items:FindFirstChild(ItemStored) then
				local Item = Instance.new("BoolValue")
				Item.Name = ItemStored
				Item.Parent = plr.Items
			end
		end
	end
	local Item = game.ServerStorage.Items:WaitForChild(ItemEquipped.Value)
	Item:Clone().Parent = plr.Backpack
	Item:Clone().Parent = plr.StarterGear
end

local function SaveData(plr)
	local Data = {
		Stats = {
			Money = plr.leaderstats.Money.Value ;
			Coins = plr.leaderstats.Coins.Value ;
			Item = plr.ItemEquipped.Value ;
		};
		Items = {};
		Pets = {};
	}
	for _,Item in pairs(plr.Items:GetChildren())do
		table.insert(Data.Items,Item.Name)
	end
	PlayerData:SetAsync(plr.UserId,Data)
end

game.Players.PlayerAdded:Connect(function(plr)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = plr
	local Money = Instance.new("NumberValue")
	Money.Name = "Money"
	Money.Value = 0
	local WorldBoost = Instance.new("NumberValue")
	WorldBoost.Name = "WorldBoost"
	WorldBoost.Value = 1
	WorldBoost.Parent = plr
	local Coins = Instance.new("NumberValue")
	Coins.Name = "Coins"
	Coins.Value = 0
	Coins.Parent = leaderstats
	local Items = Instance.new("Folder")
	Items.Name = "Items"
	Items.Parent = plr
	local StarterItem = Instance.new("BoolValue")
	StarterItem.Name = "Bronze Coin"
	StarterItem.Parent = Items
	local Cooldown = Instance.new("BoolValue")
	Cooldown.Name = "Cooldown"
	Cooldown.Value = false
	Cooldown.Parent = plr
	local ItemEquipped = Instance.new("StringValue")
	ItemEquipped.Name = "ItemEquipped"
	ItemEquipped.Value = "Bronze Coin"
	ItemEquipped.Parent = plr
	LoadData(plr,Money,Coins,ItemEquipped)
end)

game.Players.PlayerRemoving:Connect(function(plr)
	SaveData(plr)
end)

wait(5)

game.ReplicatedStorage.RemoteEvents.Give.OnServerEvent:Connect(function(plr,tool)
	if plr.Cooldown.Value == false then
		if plr.Items:FindFirstChild(tool.Name) then
			plr.Cooldown.Value = true
			local MoneyBoost = 0
			local CoinsBoost = 0
			local CoinMultiplier = 1
			local MoneyMultiplier = 1
			if mps:UserOwnsGamePassAsync(plr.UserId,6411826) then MoneyMultiplier = 2 end
			if mps:UserOwnsGamePassAsync(plr.UserId,6411823) then CoinMultiplier = 2 end
			plr.leaderstats.Money.Value = plr.leaderstats.Money.Value + tool.Configure.Money.Value + MoneyBoost * MoneyMultiplier
			plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + tool.Configure.Coins.Value + CoinsBoost * CoinMultiplier
			game.ReplicatedStorage.RemoteEvents.PopUp:FireClient(plr,"Money",tool.Configure.Money.Value + MoneyBoost * MoneyMultiplier)
			wait(1)
			plr.Cooldown.Value = false
		end
	end
end)

game.ReplicatedStorage.RemoteEvents.Buy.OnServerEvent:Connect(function(plr,tool)
	if tool:FindFirstChild("Configure") then
		local Configure = tool:FindFirstChild("Configure")
		if not plr.Items:FindFirstChild(Configure.Item.Value) then
			if plr.leaderstats.Coins.Value >= Configure.Price.Value then
				plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value - Configure.Price.Value
				local Item = Instance.new("BoolValue")
				Item.Name = Configure.Item.Value
				Item.Parent = plr.Items
			end
		end
	end
end)

game.ReplicatedStorage.RemoteEvents.EquipItem.OnServerEvent:Connect(function(plr,Item)
	if Item:FindFirstChild("Configure") then
		local Configure = Item:FindFirstChild("Configure")
		if plr.Items:FindFirstChild(Configure.Item.Value) then
			local Price = Configure.Price
			if plr.leaderstats.Coins.Value >= Price.Value then
				local Item = game.ServerStorage.Items:FindFirstChild(Configure.Item.Value)
				Item:Clone().Parent = plr.Backpack
				plr.ItemEquipped.Value = Configure.Item.Value
			end
		end
	end
end)

game.ReplicatedStorage.RemoteEvents.DeleteItem.OnServerEvent:Connect(function(plr,Item)
	for i, v in pairs(plr.Backpack:GetChildren()) do
		v:Destroy()
	end
	local char = plr.Character or plr.CharacterAdded:Wait()
	for i, v in pairs(char:GetChildren()) do
		if v:IsA("Tool") then
			v:Destroy()
		end
	end
end)

game.ReplicatedStorage.RemoteFunction.CheckIfBought = function(tool, plr) -- Problem
	if tool:FindFirstChild("Configure") then
		local Configure = tool:FindFirstChild("Configure")
		if not plr.Items:FindFirstChild(Configure.Item.Value) then
			return false
		else
			return true
		end
	end
end

game.ReplicatedStorage.RemoteFunction.CanBuy = function(tool, plr) -- this might also be a problem
	if tool:FindFirstChild("Configure") then
		local Configure = tool:FindFirstChild("Configure")
		if not plr.Items:FindFirstChild(Configure.Item.Value) then
			
			if plr.leaderstats.Coins.Value >= Configure.Price.Value then
				return true
			else
				return false
			end
			
		else
			return "player already has item"
		end
	end
end

mps.ProcessReceipt = function(Info)
	local plr = game.Players:GetPlayerByUserId(Info.PlayerId)
	if Info.ProductId == 539034514 then
		plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 1000
		game.ReplicatedStorage.RemoteEvents.PopUp:FireClient(plr,"Coins",1000)
	elseif Info.ProductId == 539034640 then
		plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 10000
		game.ReplicatedStorage.RemoteEvents.PopUp:FireClient(plr,"Coins",10000)
	elseif Info.ProductId == 539034838 then
		plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 100000
		game.ReplicatedStorage.RemoteEvents.PopUp:FireClient(plr,"Coins",100000)
	elseif Info.ProductId == 539034991 then
		plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 1000000
		game.ReplicatedStorage.RemoteEvents.PopUp:FireClient(plr,"Coins",1000000)
	end
	return Enum.ProductPurchaseDecision.PurchaseGranted
end

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like

2 things.

  • Player is passed automatically as first parameter.

  • You are missing the property of the RemoteFunction. It should be:

RemoteFunction.OnServerInvoke = function(player)

oh forgot, thanks for helping me

1 Like

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