I am making a murder game which is coming out of Alpha, but since Experimental Mode was added and restricted any one from seeing the game unless you search it really hurt the total number of visits, so I decided to turn on FE and I knew it was going to break the game and I was right, but I have no idea why, the main script, GameScript, is a server script, and reading over the article on robloxdev.com it says that client-sided scripts do not have control. I really need help because all the remote functions and events stuff are just completely alien to me, please help! I added in a few comments to areas that might seem confusing.
game.Players.PlayerAdded:connect(function(player) --Adds stats for the player
local q = Instance.new("IntValue")
q.Name = "Queue"
q.Parent = player
local l = Instance.new("BoolValue")
l.Name = "leaderstats"
local lv = Instance.new("IntValue")
lv.Name = "Level"
lv.Value = 1
lv.Parent = l
local ex = Instance.new("IntValue")
ex.Name = "XP"
ex.Value = 0
ex.Parent = l
local p = Instance.new("IntValue")
p.Name = "Points"
p.Value = 100
p.Parent = l
local i = Instance.new("BoolValue")
i.Name = "Inventory"
i.Parent = player
local m = Instance.new("BoolValue")
m.Name = "Murderer"
m.Value = "Identify"
m.Parent = i
ex.Changed:connect(function() --Handles xp
if ex.Value>math.floor(50*(1.4^lv.Value)) then
ex.Value = ex.Value-math.floor(50*(1.4^lv.Value))
lv.Value = lv.Value+1
end
end)
l.Parent = player
end)
function applyChar(player,char) --Disguises character when game starts
player.PlayerGui.GameGui.Spectate.Visible = false
player.PlayerGui.ShopGUI.Open.Visible = false
player.PlayerGui.ShopGUI.Shop.Visible = false
for _,e in ipairs(player.Character:GetChildren()) do
if e.className=="Accessory" or e.className=="Shirt" or e.className=="Pants" or e.className=="CharacterMesh" then
e:Remove()
end
end
for _,e in ipairs(char:GetChildren()) do
if e.Name=="Head" then
local h2 = e:Clone()
h2.Anchored = false
h2.Name = "Head2"
player.Character.Head.Transparency = 1
Instance.new("Weld").Parent = h2
h2.Weld.Part0 = player.Character.Head
h2.Weld.Part1 = h2
h2.Parent = player.Character
if h2:FindFirstChild("face")~=nil then
player.Character.Head.face.Texture = h2.face.Texture
h2.face:Remove()
end
player.Character.Torso.BrickColor = h2.BrickColor
player.Character["Right Arm"].BrickColor = h2.BrickColor
player.Character["Left Arm"].BrickColor = h2.BrickColor
player.Character["Right Leg"].BrickColor = h2.BrickColor
player.Character["Left Leg"].BrickColor = h2.BrickColor
if char.Name=="Keith" then
h2.BrickColor = BrickColor.new("Pastel brown")
end
script.NameGui:Clone().Parent = h2
h2.NameGui.Display.Text = char.Name
h2.NameGui.Display.Visible = true
h2.NameGui.PlayerToHideFrom = player
player.PlayerGui.GameGui.NameGui.CharN.Text = char.Name
player.PlayerGui.GameGui.NameGui.CharN.Visible = true
player.PlayerGui.GameGui.NameGui.Display.Visible = true
local nt = Instance.new("StringValue")
nt.Value = char.Name
nt.Name = "CharName"
nt.Parent = player.Character.Humanoid
elseif e.Name=="Handle" then
local hat = Instance.new("Hat")
hat.AttachmentPoint = e.CFrame:inverse()*(char.Head.CFrame*CFrame.new(0,0.5,0))
e:Clone().Parent = hat
hat.Handle.FormFactor = "Custom"
hat.Handle.Size = Vector3.new(0.2,0.2,0.2)
hat.Handle.Anchored = false
hat.Parent = player.Character
else
e:Clone().Parent = player.Character
end
end
script.OnDeath:Clone().Parent = player.Character
player.Character.OnDeath.Disabled = false
end
function msgAll(txt) --Uses gui to message players about game status (countdown, not enough players, etc.)
for _,p in ipairs(game.Players:GetChildren()) do
if p:FindFirstChild("PlayerGui")~=nil and p.PlayerGui:FindFirstChild("GameGui")~=nil then
p.PlayerGui.GameGui.Top.Text = txt
end
end
end
function getStatus(player)
if player.Character~=nil and player.Character:FindFirstChild("Humanoid")~=nil and player.Character.Humanoid.Health>0 then
return true,player.Character.Humanoid
else
return false,nil
end
end
while true do
workspace.Map:ClearAllChildren()
for i=30,1,-1 do
msgAll("Intermission: "..i)
wait(1)
end
if #(game.Players:GetChildren())<3 then
msgAll("Game needs at least 3 players...")
while #(game.Players:GetChildren())<3 do
local p = game.Players.PlayerAdded:wait()
wait(1)
if p.Character==nil then
p.CharacterAdded:wait()
end
end
end
local map = (game.ReplicatedStorage.Maps:GetChildren())[math.random(1,#(game.ReplicatedStorage.Maps:GetChildren()))]:Clone()
map.Parent = workspace.Map
local spwn = map.Spawn:GetChildren()
msgAll("")
wait(2)
local p = game.Players:GetChildren()
local mdrr = 1
for i=1,#p do
p[i].Queue.Value = p[i].Queue.Value+1
if p[i].Queue.Value>p[mdrr].Queue.Value then
mdrr = i
end
end
local s = {}
for i=1,#p do if i~=mdrr then s[#s+1] = p[i] end end
local sherrif = s[math.random(1,#s)]
local mName = p[mdrr].Name
local chars = game.ReplicatedStorage.Characters:GetChildren()
local open = {}
for i=1, #chars do open[i] = i end
for n,player in pairs(p) do
if player:FindFirstChild("PlayerGui")~=nil and player.PlayerGui:FindFirstChild("GameGui")~=nil then
local ran = math.random(1,#open)
applyChar(player,chars[open[ran]])
if n==mdrr then
game.ReplicatedStorage.NewRound:FireClient(player,2)
local tag = Instance.new("BoolValue")
tag.Name = "Murderer"
tag.Parent = player.Character.Humanoid
player.Queue.Value = 0
elseif p[n]==sherrif then
game.ReplicatedStorage.NewRound:FireClient(player,1)
local tag = Instance.new("BoolValue")
tag.Name = "Cop"
tag.Parent = player.Character.Humanoid
else
game.ReplicatedStorage.NewRound:FireClient(player,0)
end
player.Character:MoveTo(spwn[math.random(1,#spwn)].Position)
table.remove(open,ran)
end
end
local playersAlive = 0
local murdererAlive = false
local timeLeft = 150
local kills = 0
for _,p in pairs(game.Players:GetChildren()) do
if p.Character~=nil and p.Character:FindFirstChild("Humanoid")~=nil then
p.Character.Humanoid.Died:connect(function()
kills = kills+1
timeLeft = timeLeft+20
if timeLeft>100 then timeLeft=150 end
end)
end
end
wait(10)
repeat
murdererAlive = false
playersAlive = 0
for _,player in ipairs(game.Players:GetChildren()) do
local isAlive,hum = getStatus(player)
if isAlive then
if hum:FindFirstChild("Murderer")~=nil then
murdererAlive = true
elseif hum:FindFirstChild("CharName") then
playersAlive = playersAlive+1
end
end
end
wait(1)
timeLeft = timeLeft-1
game.ReplicatedStorage.TimeUpdate:FireAllClients("Time Left: "..tostring(timeLeft))
until playersAlive<=0 or not murdererAlive or timeLeft<=0
print(murdererAlive,playersAlive)
local msg,type,cnd
if murdererAlive and playersAlive>0 then
msg = "OUT OF TIME"
cnd = 1
elseif murdererAlive and playersAlive<=0 then
msg = "THE MURDERER WINS"
cnd = 2
elseif not murdererAlive and playersAlive>0 then
msg = "INNOCENTS WIN"
cnd = 3
else
msg = "NO SURVIVORS"
cnd = 4
end
if cnd==1 or cnd==3 then
for _,p in ipairs(game.Players:GetChildren()) do
if p.Character~=nil and p.Character:FindFirstChild("Humanoid")~=nil and p.Character.Humanoid:FindFirstChild("CharName")~=nil and p.Character.Humanoid.Health>0 then
p.leaderstats.Points.Value = p.leaderstats.Points.Value+3
p.leaderstats.XP.Value = p.leaderstats.XP.Value+5
end
end
if game.Players:FindFirstChild(script.Sheriff.Value)~=nil then
game.Players[script.Sheriff.Value].leaderstats.XP.Value = game.Players[script.Sheriff.Value].leaderstats.XP.Value+3
game.Players[script.Sheriff.Value].leaderstats.Points.Value = game.Players[script.Sheriff.Value].leaderstats.Points.Value+2
end
if game.Players:FindFirstChild(mName)~=nil then
game.Players[mName].leaderstats.Points.Value = game.Players[mName].leaderstats.Points.Value + ((cnd==1 and kills) or math.floor(kills/2))
game.Players[mName].leaderstats.XP.Value = game.Players[mName].leaderstats.XP.Value + ((cnd==1 and kills) or math.floor(kills/3))
end
game.ReplicatedStorage.EndRound:FireAllClients(msg,0,playersAlive,"+5 for survivors","+3 for sheriff","+"..tostring((cnd==1 and kills) or math.floor(kills/3)).." for murderer",mName,script.Sheriff.Value)
elseif cnd==2 then
if game.Players:FindFirstChild(mName)~=nil then
game.Players[mName].leaderstats.Points.Value = game.Players[mName].leaderstats.Points.Value+(kills*1)
game.Players[mName].leaderstats.XP.Value = game.Players[mName].leaderstats.XP.Value+(kills*2)
end
game.ReplicatedStorage.EndRound:FireAllClients(msg,1,0,"+"..(kills*2).." for murderer","","",mName,script.Sheriff.Value)
end
wait(6)
for _,p in ipairs(game.Players:GetChildren()) do
if p.Character==nil or p.Character:FindFirstChild("Humanoid")==nil or p.Character.Humanoid:FindFirstChild("CharName")~=nil then
p:LoadCharacter()
end
end
end

1 comment
https://scriptinghelpers.org/help/how-post-good-questions-answers