Hi, I’m having a lot of difficulty right now, trying to get these scripts to work. There’s no errors, but whatever I do doesn’t work. I’ve tried searching it up on youtube but found nothing.
What’s happening is, in the first script there’s a max people limit per this class. However, when I tested it with 4 people, everyone was that class. It is a script in ServerScriptService.
local Classes = {"Class-D", "Scientist", "Guard", "SCP"}
local Classdclass = game.ReplicatedStorage.Classdclass
local SCPClass = game.ReplicatedStorage.SCPClass
local ScientistClass = game.ReplicatedStorage.ScientistClass
local GuardClass = game.ReplicatedStorage.GuardClass
local MaxScp = 2
local SCPS = 0
local PlayerClass = ""
Players = game:GetService("Players")
game.Players.PlayerAdded:Connect(function(player)
for i, player in pairs(Players:GetPlayers()) do
PlayerClass = math.random(1, #Classes)
print(PlayerClass)
if PlayerClass == 4 and SCPS < MaxScp then
SCPClass:Fire()
SCPS = SCPS - 1
elseif SCPS > MaxScp then
print('max scps')
end
end
end)
The other script puts a max people limit per type of SCP, but everyone was the same one. It is a script in ServerScriptService.
local SCPClass = game.ReplicatedStorage.SCPClass
local scp1 = game.ReplicatedStorage:FindFirstChild("173")
local SCPClass2 = game.ReplicatedStorage.SCPClass
local scp2 = game.ReplicatedStorage:FindFirstChild("049")
local SCP173FOVEVENT = game.ReplicatedStorage.scp173fovevent
local Max173 = false
local Max049 = false
local scpscript = scp1.Script
function scp173()
if Max173 == false then
Max173 = true
scpClone = scp1:Clone()
scpscriptclone = scpscript:Clone()
scpClone.Name = "StarterCharacter"
scpClone.Parent = game.StarterPlayer
scpscriptclone.Parent = game.StarterPlayer.StarterCharacterScripts
SCP173FOVEVENT:Fire()
else if Max173 == true then
if Max049 == false then
Max049 = true
scpClone2 = scp2:Clone()
scpClone2.Name = "StarterCharacter"
scpClone2.Parent = game.StarterPlayer
end
end
end
end
SCPClass.Event:Connect(scp173)
That’s not it, when you don’t precede something with ‘local’, it gets defined globally, still works though - it’s optimization to define everything locally for faster access to values.
Won’t affect the final outcome though, will still work.
If you defined Players already right before the function, why can’t you just do
You’re doing game.Players which is the same as game:GetService(“Players”) (except the latter methodology is better), that won’t affect anything related to what the SCP is.
Putting the morph in the starter character folder will mean everyone will use that morph, so instead do something like:
morph = scp:Clone()
local oldCharacter = player.Character
player.Character = morph
oldCharacter:Remove()
morph.Parent = workspace
local SCPClass = game.ReplicatedStorage.SCPClass
local scp1 = game.ReplicatedStorage:FindFirstChild("173")
local SCPClass2 = game.ReplicatedStorage.SCPClass
local scp2 = game.ReplicatedStorage:FindFirstChild("049")
local SCP173FOVEVENT = game.ReplicatedStorage.scp173fovevent
local player = game.Players.PlayerAdded
local Max173 = false
local Max049 = false
local scpscript = scp1.Script
function scp173()
if Max173 == false then
Max173 = true
morph = scp1:Clone()
local oldCharacter = player.Character
player.Character = morph
oldCharacter:Remove()
morph.Parent = workspace
scpscriptclone = scpscript:Clone()
scpscriptclone.Parent = game.StarterPlayer.StarterCharacterScripts
SCP173FOVEVENT:Fire()
else if Max173 == true then
if Max049 == false then
morph2 = scp1:Clone()
local oldCharacter2 = player.Character
player.Character = morph
oldCharacter2:Remove()
morph2.Parent = workspace
end
end
end
end
SCPClass.Event:Connect(scp173)