I’m working on a tycoon game & I was wondering if anyone could help me with this code?
I don’t have much experience with scripting & I want to make this with 0 tutorials involved.
I have this script which allows the player to claim the tycoon & nobody else can claim it until that player leaves the game.
I scripted it so that it works with teams but I was wondering if anyone knows how I make it so that only the player on that team can do stuff in the tycoon. For example, only the player in the team can open the owner door.
I’m assuming I probably have to do a lot more then just the door as there’s going to be 6 of the same tycoon duplicated & I think that might break the game.
If anybody can help me fix this & get the tycoons working correctly, I’d appreciate it a lot.
It errored because currentPlayer has no value, which can make player nil. You could do this:
local currentPlayer = -- path to currentplayer value in owner door
local Teams = game:GetService("Teams")
local player = game.Players:FindFirstChild(currentPlayer.Value)
if player then
if player.Team == Teams["Programmer 1"] then
-- do stuff
end
end