Am I stupid? Why is this not working?

Like i said, I added prints in the module. Its right in the first line, so no infinite loop should happen.

local plot = {}

plot.Random = Random.new()

local x = {}
local y = 200
local z = 300

local FIRST_OFFSET = 200

local function fillTable()
	for i=FIRST_OFFSET, 10000, 100 do
		wait()
		if not table.find(x, i) then
			table.insert(x, i)
		end
	end
end

fillTable()

function plot.new(player:Player)
	print("Called")
	local num = 1
	
	local chosen = x[num]
	
	table.remove(x, 1)
	
	local part = Instance.new("Part", game.ReplicatedStorage.Plots)
	part.Anchored = true
	part.Size = Vector3.new(50, 1, 50)
	part.TopSurface = Enum.SurfaceType.SmoothNoOutlines
	part.BottomSurface = Enum.SurfaceType.SmoothNoOutlines
	
	part.Position = Vector3.new(chosen, y, z)
	
	local tag = Instance.new("IntValue", part)
	tag.Name = "Position"
	tag.Value = chosen
	
	local plrValue = Instance.new("StringValue", part)
	plrValue.Name = "Player"
	plrValue.Value = player and player.Name or "LOL"
end

return plot

Now that I think about it, It might lie in the for loop.

That fill table function with the wait is going to take minutes. You’re doing a lot there. The player added code won’t work until that’s done. [oops. Didn’t notice you were incrementing by hundreds. Not minutes,]

2 Likes

Bruh…

I guess I am stupid.

I put an extra zero.

BRUH

1 Like

You can remove that wait. It’s a small enough loop you’re just adding delay unnecessarily (unless for some reason you need to specifically control the timing). My initial estimate was off because I didn’t notice the amount you were incrementing by. But any waits before your player added code can make it miss you while testing.

Hold on…

Thats still not the problem.

The playerAdded event still doesnt fire

i commented out the actual module call and I added a print.

Still doesnt fire. It doesnt seem like it.

game.Players.PlayerAdded:Wait()

game.Players.PlayerAdded:Connect(function(player)
	print("Player")
	--plot.new(player)
end)

2 Likes

@tlr22

lolololololololololololololol

1 Like

do not yield the script if you need to connect PlayerAdded event, the event will be connected after palyer joined because of wait🤦‍♂️

Still doesnt print sadly. I honestly think that I need to reinstall studio or something.

step 1: open empty baseplate
step 2: create Script inside ServerScriptService
step 3: put this into the Script (and make sure its enabled set to true)

print("playeradded print script loaded")
game:GetService("Players").PlayerAdded:Connect(function(plr)
       print(plr.UserId,"joined")
end)
print("playeradded print script loaded confirmed!")

Did you ever get it to print the line right above the connection?

???

It works?

Lemme check my other script…

Omg thank you so much for your help. It turns out the loop was Indeed the problem because it ran without a condition. Thank you all for helping.

I solved the issue by simply putting the for loop in a task.spawn(function()).

2 Likes

ayo why u need loops in playeradded? :skull: why didnt u told us uve had loops in it??

Not in playerAdded, but in a module that gets fired when a player is added :slight_smile:

ayo still dont understand :skull: :skull: :skull:

in short terms

he had a loop blocking PlayerAdded from getting connected

bruh thats what i told
charcharchar

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