No functions were fired when Firing RemoteEvents - roblox

So, I want to make if a purchase is completed, a GUI will appear
#x72 is already answered it but I don't use her codes. I tried to use another code but didn't work either.
I didn't get it work but no error messages
Here's the code:
Script:
-- Products for purchases
local Donate1ProductID = 1296480045
local Donate2ProductID = 1296484976
local Donate3ProductID = 1296484935
local Donate4ProductID = 1296484932
local Donate5ProductID = 1296483595
local Donate6ProductID = 1296484931
local Donate7ProductID = 1296484933
-- Required depencies/services
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PurchaseSuccess = ReplicatedStorage.PurchaseSuccess
-- Code
MarketplaceService.ProcessReceipt = function(receiptInfo)
local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
if receiptInfo.ProductId == Donate1ProductID or Donate2ProductID or then Donate3ProductID or Donate4ProductID or Donate5ProductID or Donate6ProductID or Donate7ProductID then
PurchaseSuccess:FireAllClients()
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
LocalScript:
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = Players.LocalPlayer
local PurchaseSuccess = ReplicatedStorage:WaitForChild("PurchaseSuccess")
local playerGui = player:WaitForChild("PlayerGui")
local Main = playerGui:WaitForChild("AntiPiracyCheck")
PurchaseSuccess.OnClientEvent:Connect(function ()
Main.PurchaseSuccess:TweenPosition(
UDim2.new(0.258, 0,0.279, 0),
Enum.EasingDirection.InOut,
Enum.EasingStyle.Quad,
1,
true
)
end)
What is the problem anyway?

You have a syntax error in your server Script's if-statement, that might be why nothing is happening. You have a stray then in the middle of the condition list, and it should only be at the end.
When using an if-statement to check whether a condition is true, you need to be explicit.
if receiptInfo.ProductId == Donate1ProductID or Donate2ProductID or Donate3ProductID or Donate4ProductID or Donate5ProductID or Donate6ProductID or Donate7ProductID then
This if-statement is saying, "if the receipt's productId matches Donate1ProductID, do a thing. Or if Donate2ProductID exists, do a thing. Or if Donate3ProductID exists, do a thing..." You aren't asking if the receipt's productID matches any of the listed product ids, you are only asking if the other product ids exist. You need to explicitly ask if receiptInfo.ProductID == [THE_PRODUCT_ID] in each case...
if receiptInfo.ProductId == Donate1ProductID or
receiptInfo.ProductId == Donate2ProductID or
receiptInfo.ProductId == Donate3ProductID or
receiptInfo.ProductId == Donate4ProductID or
receiptInfo.ProductId == Donate5ProductID or
receiptInfo.ProductId == Donate6ProductID or
receiptInfo.ProductId == Donate7ProductID then
But there is a nicer way to do that, you can put all of the ids as the keys of a table and check if the receipt matches any of the known keys. Try something like this :
-- Products for purchases mapped to a message about it.
local donationIDMap = {
[1296480045] = "Donated X amount",
[1296484976] = "Donated X amount",
[1296484935] = "Donated X amount",
[1296484932] = "Donated X amount",
[1296483595] = "Donated X amount",
[1296484931] = "Donated X amount",
[1296484933] = "Donated X amount",
}
-- Required depencies/services
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PurchaseSuccess = ReplicatedStorage.PurchaseSuccess
-- Code
MarketplaceService.ProcessReceipt = function(receiptInfo)
local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
local donationMessage = donationIDMap[receiptInfo.ProductId]
local messageExists = donationMessage ~= nil
if messageExists then
-- you could send the message to the client so they know that it worked..
PurchaseSuccess:FireClient(player, donationMessage)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
-- not sure what they bought.
local message = "NO HANDLER SPECIFIED FOR PRODUCT ID : %d. %s DID NOT RECEIVE ANYTHING FOR THIS PURCHASE.":format(receiptInfo.ProductId, player.Name)
warn(message)
return Enum.ProductPurchaseDecision.NotProcessedYet
end
Then on the client you can optionally handle the message from the server like this...
PurchaseSuccess.OnClientEvent:Connect(function(donationMessage)
-- put the message into a textbox...
-- local txtBox = Main.Purchased.Message -- find the path to some ui element
-- txtBox.Text = donationMessage

The problem is, Your LocalScript was in REPLICATEDSTORAGE.

Related

Attempt to index nil to 'Takedamage'

the thing is that im making a combat system, and there is the situation with line 56 that says: enemyHumanoid:TakeDamage(Damage) and the error says: ServerScriptService.CombatSystem:56: attempt to index nil with 'TakeDamage' and i dont know what to do (also this is the entire code)
local rp = game:GetService("ReplicatedStorage")
local Combat = rp:WaitForChild("Combat")
local Debris = game:GetService("Debris")
local Animations = script:WaitForChild("Animations")
local Meshes = script:WaitForChild("Meshes")
local anims =
{
Animations:WaitForChild("Right"),
Animations:WaitForChild("Left"),
Animations:WaitForChild("Gut"),
Animations:WaitForChild("Kick"),
}
local limbs =
{
"RightHand",
"LeftHand",
"RightHand",
"RightFoot"
}
local Damage = 10
Combat.OnServerEvent:Connect(function(player,count)
local Character = player.Character
local Humanoid = Character:WaitForChild("Humanoid")
local attack = Humanoid:LoadAnimation(anims[count])
attack:Play()
local Limb = Character:WaitForChild(limbs[count])
local folder = Instance.new("Folder",Character)
folder.Name = player.Name.."Melee"
local Hitbox = Meshes:WaitForChild("Hitbox"):Clone()
Hitbox.CFrame = Limb.CFrame
Hitbox.Parent = folder
Debris:AddItem(Hitbox,.5)
local weld = Instance.new("ManualWeld")
weld.Part0 = Hitbox
weld.Part1 = Limb
weld.C0 = weld.Part0.CFrame:ToObjectSpace(weld.Part1.CFrame)
weld.Parent = weld.Part0
Hitbox.Touched:Connect(function(Hit)
if Hit:IsA("BasePart") then
if not Hit:IsDescendantOf(Character) then
local enemyHumanoid = Hitbox.Parent:FindFirstChild("Humanoid")
if Humanoid then
Hitbox:Destroy()
enemyHumanoid:TakeDamage(Damage)
end
end
end
end)
Combat:FireClient(player)
end)
i haven't try a lot but it keeps getting errors
Welcome to StackOverflow! :FindFirstChild("Humanoid") returns nil if the Humanoid doesn't exist, which is why enemyHumanoid:TakeDamage() isn't working. Try using this snippet in place of the current Hitbox.Touched function:
Hitbox.Touched:Connect(function(Hit)
if Hit:IsA("BasePart") and not Hit:IsDescendantOf(Character) then
local enemyHumanoid = Hitbox.Parent:FindFirstChild("Humanoid")
if Humanoid then
Hitbox:Destroy()
if enemyHumanoid then -- Make sure enemyHumanoid exists and isn't nil
enemyHumanoid:TakeDamage(Damage)
end
end
end
end)

Roblox: Data is Saving, But Fails when trying to load?

So what I've been trying is to Save a certain "Text" to the DataStore from a TextLabel, The Data Saves Successfully, But when trying to load it gives me just gives me a "Failed", Any Help?
Here's a Quick Video: https://www.youtube.com/watch?v=W-J6U8zmATk&feature=youtu.be
Script:
local DataStoreService = game:GetService("DataStoreService")
local IDStorage = DataStoreService:GetDataStore("IDStorage3")
elseif Player.Team.Name == "Intelligence Agency" then
if Player:IsInGroup(7503826) or Player:GetRankInGroup(7465879) >= 251 then
Rank.User.Text = "[REDACTED]"
Rank.User.Back.Text = "[REDACTED]"
Rank.Rank.TextColor3 = Color3.new(0.827451, 0, 0)
game.ReplicatedStorage.NewID.OnServerEvent:Connect(function(player, playerToID, AssignedID)
if player:IsInGroup(7465879) then
local success, err = pcall(function()
IDStorage:SetAsync(playerToID, AssignedID)
end)
if success then
print("Data Assigned") -- Data Works and Saves
else
warn("Failed to Save")
end
end
end)
local ID = IDStorage:GetAsync(Player)
if ID then
print(ID)
else
warn("Failed") -- Always Returns me this.
Rank.Rank.Text = "0"
end
Rank.User.Text = "[REDACTED]"
Rank.User.Back.Text = "[REDACTED]"
end
The DataStore:GetAsync(key) function expects a string for the key. It looks like you're passing in a Player object and not the player's username, which you said was the key that you were storing the data in.
Try this swapping this line
local ID = IDStorage:GetAsync(Player)
for this instead :
local success, result = pcall(function()
local key = Player.Name
return IDStorage:GetAsync(key)
end
if success then
print("Got Id : ", result)
local ID = result
if ID then
-- do stuff with the result
else
-- looks like a new player with no saved data
end
else
warn("failed to get id with error :", result)
-- do something to handle the error, like retry
end
Something to be careful about when saving data is that usernames can change. If I were to change my name, the next time I joined this game, all of my progress would be gone because the name doesn't match up with the saved key. That is why a player's userId tends to be the recommend key.

Accessing values inside an object

When the user of the application selects a card, I want to be able to retrieve the user's 'stripeID', however whenever I print paymentContext.selectedPaymentOption I am able to see the data that I need, but cannot access it.
Language used: swift.
I am using stripe for the payment system in Swift, and I am also using the stripe UI to allow users to add their credit card information to the app.
your comments will be very helpful
The message I am receiving is:
STPPaymentMethod: 0x28105c080; stripeId = pm_1GuuilCs27VSYM8G5UUd3q2S;
auBECSDebit = (null); bacsDebit = (null); billingDetails =
<STPPaymentMethodBillingDetails: 0x282b4d3c0; name = (null); phone =
(null); email = (null); address = <STPPaymentMethodAddress:
0x281d2e3f0; line1 = (null); line2 = (null); city = (null); state =
(null); postalCode = 6643; country = (null)>>; card =
<STPPaymentMethodCard: 0x281affea0; brand = Mastercard; checks =
<STPPaymentMethodCardChecks: 0x2831c9cb0; addressLine1Check: (null);
addressPostalCodeCheck: pass; cvcCheck: pass>; country = US; expMonth
= 2; expYear = 2054; funding = credit; last4 = 4444; fingerprint = TBj8N5wToO3eEbfK; threeDSecureUsage =
<STPPaymentMethodThreeDSecureUsage: 0x283f38840; supported: YES>;
wallet = (null)>; cardPresent = (null); created = 2020-06-17 06:26:04
+0000; customerId = cus_HTrYPeMU1l0pcB; ideal = (null); fpx = (null); sepaDebit = (null); liveMode = NO; metadata = { }; type = card
Any comments or assistance you can provide on this issue would be a great help.
Normally, this option should be performed in the backend,so you can list them or target the exact one.
Here how you retrieve an account: https://stripe.com/docs/api/accounts/retrieve?lang=node

How to use timer.performWithDelay with a method call

I'm using a Lua class to create two objects, each of which must check where the other is to determine their movement. I'm attempting to use timer.performWithDelay to have them check every second, but for some reason when I try to do this, the line
o.moveCheckTimer = timer.performWithDelay(1000, o:moveCheck, 0)
in the class constructor throws an error stating that "Function arguments are expected near ','".
I have attempted to use an anonymous function like this:
o.moveCheckTimer = timer.performWithDelay(1000, function() o:moveCheck() end, 0)
but that causes the timer of both objects to only call the function for the most recent object that was created and not for itself (also very confusing behavior, and if anyone knows why this happens I would love to learn why).
I have dug through the API and info on method calls thoroughly, but I can't seem to find anything that uses them both together, and I feel like I'm missing something.
How can I use the method call as the listener for this timer?
Here is the full constructor:
Melee = {}
Melee.__index = Melee
function Melee:new(id, name, lane, side)
local o = {}
setmetatable(o, Melee)
o.id = id
o.name = name
o.lane = lane
o.side = side
if name == "spearman" then
o.maxhp = 100
o.range = 1
o.damage = {10, 20}
o.imageName = "images/rebels/spearman.png"
else
error("Attempted to create melee unit with undefined name")
end
o.hp = o.maxhp
--Display self
o.image = display.newImageRect(mainGroup, "images/rebels/spearman.png", 80, 80)
o.image.x = 0
o.image.y = lanes[lane]
o.image.anchorY = 1
if side == 2 then
o.image.xScale = -1
o.image:setFillColor(0.8)
o.image.x = display.contentWidth - 100
end
--Move and attack
local destination = display.contentWidth
if side == 2 then
destination = 0
end
o.moving = 1
o.movement = transition.to(o.image, {x = destination, time = 30000+math.random(-200,200)})
o.moveCheckTimer = timer.performWithDelay(1000, o:moveCheck, 0)
--o.attackTimer = timer.performWithDelay(1000, self:attack, 0)
return o
end

NotesSession.GetDataBase method is returning null value

I have a c# class which was written to read the lotus emails for any attachments and save it to the local drive. It was working fine when I pass "" as first parameter to GetDataBase method and full path of .nsf file of my local system as second argument. But, if I remove "" and I specify my local system full name as first argument it is returning null value.
Is it problem with any permissions? If so, it should not work even when I pass "" as first parameter. Otherwise, should I have any other permissions at system/server level?
Please help me in this issue.
Finally, I could do it in the following way. And I thought of posting it to some one can atleast not to suffer again.
Following code is to read the attachment from the lotus emails and save it to the physical location.
string lotusServerName = ConfigurationSettings.AppSettings["Lotus_Server"].ToString();
string lotusDBFilePath = ConfigurationSettings.AppSettings["Lotus_DB_File_Path"].ToString();
string password = ConfigurationSettings.AppSettings["Password"].ToString();
string sourceFolder = ConfigurationSettings.AppSettings["Source_Folder"].ToString();
string targetFolder = ConfigurationSettings.AppSettings["Target_Folder"].ToString();
string documentsFolder = ConfigurationSettings.AppSettings["Documents_Folder"].ToString();
//Creating the notes session and passing password
NotesSession session = new NotesSession();
session.Initialize(password);
//Getting the DB instance by passing the servername and path of the mail file.
//third param "false" will try to check the DB availability by opening the connection
//if it cannot open, then it returns null.
NotesDatabase NotesDb = session.GetDatabase(lotusServerName, lotusDBFilePath, false);
//Get the view of the source folder
NotesView inbox = NotesDb.GetView(sourceFolder);
//looping through each email/document and looking for the attachments
//if any attachments found, saving them to the given specified location
//moving the read mails to the target folder
NotesDocument docInbox = null;
int docCnt = inbox.EntryCount;
for (int currDoc = 0; currDoc < docCnt; currDoc++) {
docInbox = inbox.GetFirstDocument();
object[] items = (object[])docInbox.Items;
foreach (NotesItem nItem in items) {
if (nItem.Name == "$FILE") {
NotesItem file = docInbox.GetFirstItem("$File");
string fileName = ((object[])nItem.Values)[0].ToString();
NotesEmbeddedObject attachfile = (NotesEmbeddedObject)docInbox.GetAttachment(fileName);
if (attachfile != null) {
attachfile.ExtractFile(documentsFolder + fileName);
}
}
}
docInbox.PutInFolder(targetFolder, true);//"true" creates the folder if it doesn't exists
docInbox.RemoveFromFolder(sourceFolder);
}
//releasing resources
if (session != null)
session = null;
if (NotesDb != null)
NotesDb = null;
if (inbox != null)
inbox = null;
if (docInbox != null)
docInbox = null;
Following is values read from .config file.
The above code will work properly if you alredy have lotus mail client in your system and you are able to access mails from your mail server. You don't require any other previliges.