What's wrong in this script? im very confused

its a system for my game like mm2

local hayatabicim = {}
local plrs = game.Players
function checkifserifkatil(serif, katil)
if serif == katil then
print(“Code-1 Status”)
local yeniserif = plrs:GetChildren()[math.random(1, #plrs:GetChildren())]
game.ReplicatedStorage.katil.Value = tostring(katil)
game.ReplicatedStorage.serif.Value = tostring(yeniserif)
checkifserifkatil(yeniserif, katil)
end
end

while wait(1) do
local katil = plrs:GetChildren()[math.random(1,#plrs:GetChildren())]
local serif = plrs:GetChildren()[math.random(1,#plrs:GetChildren())]
game.ReplicatedStorage.katil.Value = tostring(katil)
game.ReplicatedStorage.serif.Value = tostring(serif)
print(katil)
print(serif)
checkifserifkatil()
local katilgui = game.ReplicatedStorage.tehlikeli.katil:Clone()
local pro = katilgui:Clone()
pro.Parent = game.Players[tostring(game.ReplicatedStorage.katil.Value)].PlayerGui
end

Does the script print any errors in the output?

yeah it prints “Nil is not valid member of game.Players”

can someone tell me whats the problem idk what to do

Screenshot the output, it would be easier to read.

1 Like

error prints line 24 is wrong

unknown

Find a line of code with a comment:

local hayatabicim = {}
local plrs = game.Players
function checkifserifkatil(serif, katil)
	if serif == katil then
		print("Code-1 Status")
		local yeniserif = plrs:GetChildren()[math.random(1, #plrs:GetChildren())]
		game.ReplicatedStorage.katil.Value = tostring(katil)
		game.ReplicatedStorage.serif.Value = tostring(yeniserif)
		checkifserifkatil(yeniserif, katil)
	end
end

while wait(1) do
	local katil = plrs:GetChildren()[math.random(1,#plrs:GetChildren())]
	local serif = plrs:GetChildren()[math.random(1,#plrs:GetChildren())]
	game.ReplicatedStorage.katil.Value = tostring(katil)
	game.ReplicatedStorage.serif.Value = tostring(serif)
	print(katil)
	print(serif)
	checkifserifkatil() -- No parameters? Both paramteres are nil by default or I'm just wrong and this is totally fine.
	local katilgui = game.ReplicatedStorage.tehlikeli.katil:Clone()
	local pro = katilgui:Clone()
	pro.Parent = game.Players[tostring(game.ReplicatedStorage.katil.Value)].PlayerGui
end

Believe me, because my English is very bad, I didn’t understand what you said, should I write a value there

Change your code to this and check output for serif and katil

local hayatabicim = {}
local plrs = game.Players
function checkifserifkatil(serif, katil)
	print("serif and katil: ")
	print(serif, katil) -- Look for this in the output after running the game
	print()
	
	if serif == katil then
		print("Code-1 Status")
		local yeniserif = plrs:GetChildren()[math.random(1, #plrs:GetChildren())]
		game.ReplicatedStorage.katil.Value = tostring(katil)
		game.ReplicatedStorage.serif.Value = tostring(yeniserif)
		checkifserifkatil(yeniserif, katil)
	end
end

while wait(1) do
	local katil = plrs:GetChildren()[math.random(1,#plrs:GetChildren())]
	local serif = plrs:GetChildren()[math.random(1,#plrs:GetChildren())]
	game.ReplicatedStorage.katil.Value = tostring(katil)
	game.ReplicatedStorage.serif.Value = tostring(serif)
	checkifserifkatil()
	local katilgui = game.ReplicatedStorage.tehlikeli.katil:Clone()
	local pro = katilgui:Clone()
	pro.Parent = game.Players[tostring(game.ReplicatedStorage.katil.Value)].PlayerGui
end
1 Like

Alright! Thank you so much for your attention :slight_smile: