- What do you want to achieve?
i want my running system to work!
- What is the issue?
after i make the player’s character reload the running system doesn’t work
- What solutions have you tried so far?
nothing that i could think of
local module = {}
local killer = game.Teams.Killer
local survivor = game.Teams.Survivors
local lobby = game.Teams.Lobby
local sendchoosenplayer = game.ReplicatedStorage:WaitForChild("SendChosenPlayerRemoteEvent")
local SurvivorAndTimerRemoveEvent = game.ReplicatedStorage:WaitForChild("SurvivorAndTimerRemoveEvent")
local SurvivorRemoveEvent = game.ReplicatedStorage:WaitForChild("SurvivorRemoteEvent")
local KillerRemoveEvent = game.ReplicatedStorage:WaitForChild("KillerRemoteEvent")
local PlayersGUIRemoteEvent = game.ReplicatedStorage:WaitForChild("PlayersGUIRemoteEvent")
local isaacmodelskin = game.ServerStorage.Skins.Isaac.StarterCharacter
function module.Roundsystem(playerstable)
local isready = false
local guifalseortrue = true
local guifalseortruesurvivors = true
local survivorcount = 0
local function checksurvivors()
survivorcount = 0
for _, player in pairs(playerstable) do
if player.Team == survivor then
survivorcount += 1
end
end
end
local discconectdeath = nil
task.wait(7)
local chosenIndex = math.random(1, #playerstable)
local player = playerstable[chosenIndex]
local character = isaacmodelskin:Clone()
character.Name = player.Name
player.Team = killer
player.Character = character
character.Parent = workspace
local humanoid = character:WaitForChild("Humanoid")
local root = character:WaitForChild("HumanoidRootPart")
repeat
task.wait()
until player.Character == character
and character.Parent == workspace
and humanoid.Parent == character
and root.Parent == character
task.wait(0.2)
for _, otherplayers in pairs(playerstable) do
if otherplayers == player then
print("this is the killer")
else
otherplayers.Team = survivor
if otherplayers:FindFirstChild("Hearts") then
PlayersGUIRemoteEvent:FireClient(otherplayers, guifalseortruesurvivors)
otherplayers:FindFirstChild("Hearts").Value = 3
else
PlayersGUIRemoteEvent:FireClient(otherplayers, guifalseortruesurvivors)
local Hearts = Instance.new("IntValue")
Hearts.Parent = otherplayers
Hearts.Value = 3
Hearts.Name = "Hearts"
end
end
end
sendchoosenplayer:FireClient(player, player, guifalseortrue)
isready = true
for _, survivorsteam in pairs(playerstable) do
if survivorsteam.Team == survivor then
local othersurvivorshumanoids = survivorsteam.Character:WaitForChild("Humanoid")
discconectdeath = othersurvivorshumanoids.Died:Connect(function()
survivorcount -= 1
survivorsteam.Team = lobby
print(survivorcount)
survivorsteam:LoadCharacterAsync()
end)
end
end
if isready == true then
for timer = 30, 0 , -1 do
for _, othersurvivors in pairs(playerstable) do
local othersurvivorshumanoids = othersurvivors.Character:WaitForChild("Humanoid")
if othersurvivors.Team == survivor then
checksurvivors()
print(survivorcount)
task.wait(1)
SurvivorAndTimerRemoveEvent:FireAllClients(timer, playerstable, survivorcount)
if survivorcount <= 0 then
KillerRemoveEvent:FireAllClients()
module.EndRound(othersurvivors, player)
break
elseif timer <= 0 and survivorcount >= 1 or not player then
SurvivorRemoveEvent:FireAllClients()
module.EndRound(othersurvivors, player)
break
end
end
end
end
end
end
function module.EndRound(othersurvivors, player, guifalseortrue, guifalseortruesurvivors)
guifalseortrue = false
guifalseortruesurvivors = false
if othersurvivors and player then
sendchoosenplayer:FireClient(player, player, guifalseortrue)
PlayersGUIRemoteEvent:FireClient(othersurvivors, guifalseortruesurvivors)
othersurvivors.Team = lobby
player.Team = lobby
othersurvivors:LoadCharacterAsync()
player:LoadCharacterAsync()
end
end
return module
this is my server sided module
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local killer = game:GetService("Teams").Killer
local iswalking = true
local gui = player:WaitForChild("PlayerGui"):WaitForChild("HeartAndPlayerGUI")
local StaminaBar = gui:WaitForChild("Frame"):WaitForChild("StaminaBar")
local StaminaBarText = gui:WaitForChild("Frame"):WaitForChild("StaminaBarText")
local PlayersGUIRemoteEvent = game.ReplicatedStorage:WaitForChild("PlayersGUIRemoteEvent")
local changeattributeconnection = nil
local MaximumStamina = 100
local CurrentStamina = MaximumStamina
local CurrentDrain = "Drain"
local CurrentGrow = "Grow"
local CurrentAction = nil
local ContextActionService = game:GetService("ContextActionService")
local function drainbarandtime()
CurrentAction = CurrentDrain
for i = CurrentStamina, 0, -1 do
if CurrentAction ~= CurrentDrain then
break
end
task.wait(0.05)
CurrentStamina = i
StaminaBar.Size = UDim2.fromScale(i / 172, 0.208)
StaminaBarText.Text = i .. "/100"
if CurrentStamina <= 0 then
humanoid.WalkSpeed = 16
break
end
end
end
local function growbarandtime()
CurrentAction = CurrentGrow
for i = CurrentStamina, MaximumStamina do
if CurrentAction ~= CurrentGrow then
break
end
task.wait(0.35)
CurrentStamina = i
StaminaBar.Size = UDim2.fromScale(i / 172, 0.208)
StaminaBarText.Text = i .. "/100"
if CurrentStamina >= MaximumStamina then
break
end
end
end
local function sprint(actionName, inputState)
if actionName == "Sprint" and inputState == Enum.UserInputState.Begin then
if player.Team == killer then
return
end
CurrentAction = CurrentDrain
humanoid.WalkSpeed = 30
drainbarandtime()
end
if actionName == "Sprint" and inputState == Enum.UserInputState.End then
humanoid.WalkSpeed = 16
CurrentAction = CurrentGrow
growbarandtime()
end
end
PlayersGUIRemoteEvent.OnClientEvent:Connect(function(guifalseortruesurvivors)
if guifalseortruesurvivors == true then
gui.Enabled = true
changeattributeconnection = humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
if humanoid.MoveDirection.Magnitude > 0 and iswalking == true then
ContextActionService:BindAction(
"Sprint",
sprint,
true,
Enum.KeyCode.LeftShift
)
ContextActionService:SetPosition(
"Sprint",
UDim2.new(0.369,0,0.5,0)
)
iswalking = false
elseif humanoid.MoveDirection.Magnitude <= 0 and iswalking == false then
iswalking = true
end
end)
elseif guifalseortruesurvivors == false then
changeattributeconnection:Disconnect()
gui.Enabled = false
ContextActionService:UnbindAction("Sprint")
end
end)
this is my local script, i know its kinda messy but its my first time making these kinds of system’s and any help is greatly appreciated.