Help with if/else script

So, I am trying to make a whitelist system for something I am making. And I have this script,


local HttpService = game.HttpService
warn("Checking for purches")
	local URL = "https://api.cheesycorp.tk/pole/".. game.CreatorId
	local ReceivedData = HttpService:GetAsync(URL)
	local Data = HttpService:JSONDecode(ReceivedData)
	print(URL)
	print(game.CreatorId)
local user = Data[1].userid
print(user)
	if user == game.CreatorId then
		warn("Purches found.")
		print(ReceivedData)
			script.Script.Disabled = false
			script.Script:Clone().Parent = game.Workspace
			script.ScreenGui:Clone().Parent = game.StarterGui
			else warn("No purches found. Deleteing")
				script:Destroy()
	end

I am wondering what is happening. Because when I run the script, I get the else part instead. I want to know what this is happening, and If I can prevent it from happening.

1 Like

I can’t see the else code for some reason? Is there even any?

When you do print(user) what do you get?

Are you testing this in studio (run) or on a live server? The CreatorId variable is always 0 while in studio.

1 Like

@Crowdsource It seemed to pick up the creator id and output the right thing. @archisaurus When I print user I get the same id as the creator id and @IAmPinleon

else warn("No purches found. Deleteing")
				script:Destroy()

That is the else code.

1 Like
  16:58:13.103 - Checking for purches
Realism Mod is currently running v2.08!
  https://api.cheesycorp.tk/pole/5196118
  5196118 (This is the creatorId)
  16:58:16.437 - No purches found. Deleteing

That is what I get from running the code.

Are you the CREATOR of the game? Or you can just edit it?

It is a group, and yes I own the group and the group has acess.

What does the REST API do?

The creator id you guys are using doesn’t seem to exist, it just leads me to an random account, while i thought/think that it would bring me into your account.

It is connected to my DB. So, unless I put the data in wrong it should work.

It’s owned by a group

2 Likes

[Reply deleted, 30 charsssssssss]

This is what it is based off of.

Can I know what the REST API returns. Also game.creatorId will be the Id of the group that owns the game

[{“userid”:“5196118”,“date-bought”:“2020-04-18T00:00:00.000Z”}]

This is the endpoint. https://api.cheesycorp.tk/pole/5196118

I got false. Ima try this in a real game.

I think the problem is that game.creatorId is a Number and whatever the userid you’re API returns is a string

One reason this might not be working is because if game.CreatorId is a group id like @LukaDev_0 has mentioned then user == game.CreatorId will never be true, because i’m pretty sure that user is meant to be a user id no? , thus:

    warn("Purches found.")
	print(ReceivedData)
	script.Script.Disabled = false
	script.Script:Clone().Parent = game.Workspace
	script.ScreenGui:Clone().Parent = game.StarterGui

Would never run

2 Likes