Unable to cast Instance to int64

I am trying to make a tipping system in which staff can upload their own gamepasses as donation options!

I’ve made This ScreenGui:

image

On my LocalScript when FocusIsLost on the TextBox, it fires a RemoteEvent with the value. It also checks if it’s a number with tonumber(text).

I’ve added print statements, and I’ve seen it prints before and after the RemoteEvent is fired.

On my ServerScript I have the following script:

game.Players.PlayerAdded:Connect(function(plr)

	game.ReplicatedStorage.Edit.OnServerEvent:Connect(function(id)

                print(id)
		local clone = script.Template:Clone()
		clone.Id.Text = tostring(id)
		clone.PriceValue.Text = game.MarketplaceService:GetProductInfo(id, Enum.InfoType.GamePass) --Line 8
		clone.Parent = plr.PlayerGui.TipGui.Tips.ScrollingFrame
		local success, err = pcall(function()
			clone.PriceValue.Text = game.MarketplaceService:GetProductInfo(id, Enum.InfoType.GamePass).PriceInRobux.." R$"
		end)

		if not success then

			game.ReplicatedStorage.Error:FireClient(plr, true)
		else
			game.ReplicatedStorage.Error:FireClient(plr, false)
		end

	end)
end)

The error I’m getting is Unable to cast Instance to int64, from Line 8 so the script doesn’t continue.

It also doesn’t print the id.

game.ReplicatedStorage.Edit.OnServerEvent:Connect(function(plr,id)

                print(id)
		local clone = script.Template:Clone()
		clone.Id.Text = tostring(id)
		clone.PriceValue.Text = game.MarketplaceService:GetProductInfo(id, Enum.InfoType.GamePass) --Line 8
		clone.Parent = plr.PlayerGui.TipGui.Tips.ScrollingFrame
		local success, err = pcall(function()
			clone.PriceValue.Text = game.MarketplaceService:GetProductInfo(id, Enum.InfoType.GamePass).PriceInRobux.." R$"
		end)

		if not success then

			game.ReplicatedStorage.Error:FireClient(plr, true)
		else
			game.ReplicatedStorage.Error:FireClient(plr, false)
		end

	end)
game.ReplicatedStorage.Edit:FireServer(123456789 --//id) 

FireServer() sets player default . when you get the event signal the first argument is player (always)

so you don’t need to add game.Players.PlayerAdded:Connect(function(plr).

Thank you so much for the clarification!

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