If Check is never called then that error should not print. Can you edit one of your previous posts to have the full code exactly as it is now?
Current code
function Check(player)
print("In Check")
if CheckV == true then
MarketplaceService:PromptPurchase(player, ITEM_ID)
BindE:Fire()
print("Read... \n Continuing")
end
if CheckV2 == true then
MarketplaceService:PromptPurchase(player, ITEM_ID2)
end
if CheckV3 == true then
MarketplaceService:PromptPurchase(player, ITEM_ID3)
end
if CheckV == false and CheckV2 == false and CheckV3 == false then
print("Kick Detected")
player:Kick("You Do Not Own Any Items From The Event")
end
end
Players.PlayerAdded:Connect(Check)
--Check(Players)
You can try to add a print statement at the beginning of the Check function to verify if itās being called when a player is added:
function Check(player)
print("Check function called for player:", player.Name)
-- Rest of your code
end
And you should ensure that the PlayerAdded event is registered properly. You can add a print statement outside the function to check if itās being registered:
Players.PlayerAdded:Connect(function(player)
print("PlayerAdded event triggered for player:", player.Name)
end)
The entire file, not just the code you think the problem is in.
I attempted the 2nd print idea, it printed nothing and skipped over both the function and that
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local BindE = game.ServerStorage.Purchase
local BindE2 = game.ServerStorage.Purchase2
local BindE3 = game.ServerStorage.Purchase3
local CheckV = game.ServerStorage.Check1.Value
local CheckV2 = game.ServerStorage.Check2.Value
local CheckV3 = game.ServerStorage.Check3.Value
local Check = game.ServerStorage.Check1
local Check2 = game.ServerStorage.Check2
local Check3 = game.ServerStorage.Check3
local ITEM_ID = 2598774005 --offered item
local ASSET_ID = 9255011 --owned item
local ASSET_NAME = "Silverthorn Antlers" --owned item name
local ITEM_ID2 = 25987754005 --offered item
local ASSET_ID2 = 9255011 --owned item
local ASSET_NAME2 = "Silverthorn Antlers" --owned item name
local ITEM_ID3 = 25987748005 --offered item
local ASSET_ID3 = 9255011 --owned item
local ASSET_NAME3 = "Silverthorn Antlers" --owned item name
wait(5)
print("ok")
function Check(player)
print("In Check")
if CheckV == true then
MarketplaceService:PromptPurchase(player, ITEM_ID)
BindE:Fire()
print("Read... \n Continuing")
end
if CheckV2 == true then
MarketplaceService:PromptPurchase(player, ITEM_ID2)
end
if CheckV3 == true then
MarketplaceService:PromptPurchase(player, ITEM_ID3)
end
if CheckV == false and CheckV2 == false and CheckV3 == false then
print("Kick Detected")
player:Kick("You Do Not Own Any Items From The Event")
end
end
Players.PlayerAdded:Connect(Check)
--Check(Players)
Players.PlayerAdded:Connect(function(player)
print("PlayerAdded event triggered for player:", player.Name)
end)
All the code, this is the script being enabled by another script
You should make sure that the code where you register the PlayerAdded
event is being executed. Ensure that it is not inside a conditional statement or function that might prevent it from running x
currently it is outside of any loop statement, a normal print works but the print at the very end does not, like its not being picked up by the script
Please provide more information about your script setup, such as where the script is located and how it is being enabled or triggered by another script. Additionally if you could provide me with more snippets of the code, it would be helpful in identifying the issue X
Can you make a fresh place with just this script so we know its not something else causing it? Also you shouldnāt use enabling / disabling scripts as a way to control them, it is not predictable what will happen.
this is the script enabling the main script
wait()
game.ServerScriptService.ScriptCheck.Enabled = true
print("Enabled")
Then the main script
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local BindE = game.ServerStorage.Purchase
local BindE2 = game.ServerStorage.Purchase2
local BindE3 = game.ServerStorage.Purchase3
local CheckV = game.ServerStorage.Check1.Value
local CheckV2 = game.ServerStorage.Check2.Value
local CheckV3 = game.ServerStorage.Check3.Value
local Check = game.ServerStorage.Check1
local Check2 = game.ServerStorage.Check2
local Check3 = game.ServerStorage.Check3
local ITEM_ID = 2598774005 --offered item
local ASSET_ID = 9255011 --owned item
local ASSET_NAME = "Silverthorn Antlers" --owned item name
local ITEM_ID2 = 25987754005 --offered item
local ASSET_ID2 = 9255011 --owned item
local ASSET_NAME2 = "Silverthorn Antlers" --owned item name
local ITEM_ID3 = 25987748005 --offered item
local ASSET_ID3 = 9255011 --owned item
local ASSET_NAME3 = "Silverthorn Antlers" --owned item name
wait()
print("ok")
function Check(player)
print("In Check")
if CheckV == true then
MarketplaceService:PromptPurchase(player, ITEM_ID)
BindE:Fire()
print("Read... \n Continuing")
end
if CheckV2 == true then
MarketplaceService:PromptPurchase(player, ITEM_ID2)
end
if CheckV3 == true then
MarketplaceService:PromptPurchase(player, ITEM_ID3)
end
if CheckV == false and CheckV2 == false and CheckV3 == false then
print("Kick Detected")
player:Kick("You Do Not Own Any Items From The Event")
end
end
Players.PlayerAdded:Connect(Check)
--Check(Players)
Players.PlayerAdded:Connect(function(player)
print("PlayerAdded event triggered for player:", player.Name)
end)
Both located in serverscriptservice
That might be it, Iāll try replacing it with a timer at the beginning
Ah! There is one issue in the main script that may be causing the problem, In the Check function, you are missing the player parameter declaration. Add it! Itāll allow the function to receive the player object when it is called X
What do you mean? The player in Check(player)
is the declaration.
The function named Check does shadow the global named Check, though, which is probably its own mistake.
So true sis! @fern2305 you can either rename the check function to something else that doesnāt conflict with the global variable, or you can rename the global variable to avoid the conflict X
I just renamed it, the entire function is being ignored like before, for some reason its not even firing any errors its just no longer working
You can try and check if the enabling script is running and correctly enabling the main script. Verify that the enabling script is executing the line game.ServerScriptService.ScriptCheck.Enabled = true
as expected, you can also make sure that the PlayerAdded
event is being triggered. You can add a print statement outside the CheckFunction
to check if the event is firing:
Players.PlayerAdded:Connect(function(player)
print("PlayerAdded event triggered for player:", player.Name)
end)
If this print statement is not being executed, it indicates that the PlayerAdded
event might not be firing properly. Double check that you have the correct event name and that the event registration code is placed in a location where it can run
tried it, still not giving me an output, both those functions are being ignored, maybe because thereās a wait parameter? Im going to try removing it
If you want the script to start executing immediately without any delay, you can remove the wait()
function from the script
that was it, thank you so much