I don’t know much about modules yet, so I don’t know if I’m doing it right. I have a module with the reset function, I want to trigger this function in the server script, when the player dies or reset, it clears the values. It is not cleaning when the player dies, which may be wrong, in both scripts.
local module = {}
local function reset()
local parentModel = script.Parent
parentModel.BluePlayer.Material = "Plastic"
parentModel.RedPlayer.Material = "Plastic"
parentModel.turn.Value = "NONE"
parentModel.blueEmpty.Value = true
parentModel.redEmpty.Value = true
parentModel.redPlayer.Value = "EMPTY"
parentModel.bluePlayer.Value = "EMPTY"
parentModel.nTurn.Value = 1
end
function module.died() -- have to specify something within the () ?
reset()
end
return module
local moduleScript = require(script.Parent.ModuleScript)
local parentModel = script.Parent
local name1 = script.Parent.redPlayer.value
local player1 = game.Players:FindFirstChild(name1)
local name2 = script.Parent.bluePlayer.Value
local player2 = game.Players:FindFirstChild(name2)
function died1(player1) -- is this right?
print("died")
moduleScript.died()
end
function died2(player2) -- is this right?
print("died")
moduleScript.died()
end
player1.Died:connect(died1)
player2.Died:connect(died2)
