Im new at scripting so im trying to make a tycoon game to improve myself. I made a script and it seems correct, there is no any errors on Output but nothing happens when im trying it.
local f = true
local screenn = script.Parent.Parent.Parent.monitor.screen
script.Parent.ChildAdded:Connect(function(Child)
if Child.Name == "SeatWeld" and f == true then
f = false
screenn.BrickColor = BrickColor.new("Steel blue")
local player = game.Players:GetPlayers()
if player ~= nil then
if script.Parent.Parent.Parent.Parent.Parent.Owner.Value == player.Name and f == false then
local stats = game.ServerStorage.PlayerMoney:FindFirstChild(player)
stats.Value = stats.Value + 10
wait(2)
f = true
end
end
end
end)
script.Parent.ChildRemoved:Connect(function(Child)
if Child.Name == "SeatWeld" and f == false then
f = true
screenn.BrickColor = BrickColor.new("Black")
end
end)
After "if player ~= nil then" part is doing nothing but screen's color is changing. So the error is after this (if player ~= nil then) part. I didnt understand whats wrong with it.
(Btw this scripts goal is when player sitting onto chair, he will get 10 money every 2 seconds and when he isnt sitting then he wouldnt.)

8 comments
Do you want to make the player sit on line 10
No player is sitting on line 5 when he sits "childadding" connects function
What script is it local or server script and what is it placed in?
Also on line 9 try local Players = game:GetService("Players")
Its server script and can i use local players in server script?
Tried local players and didnt worked.
Try this in server script [[game.Players.PlayerAdded:connect(function(player) ]]
I think its because you didnt reference the player added event.