I was making custom chat system and I faced this "bug".
just textbox returns "", not nil.
and there is no any error. even without
string.len(script.Parent.Parent.message.Text) > 0
"if" part.
local db = false
local TextService = game:GetService("TextService")
script.Parent.MouseButton1Click:Connect(function ()
local plr = script.Parent.Parent.Parent.Parent.Parent.Parent
local dn = plr.Character.Humanoid.DisplayName
local muted = script.Parent.muted.Value
local mod = script.Parent.moderator.Value
if db == false and muted == false and string.len(script.Parent.Parent.message.Text) > 0 then
db = true
local ts = 16
local msg = script.Parent.Parent.chat.message0:Clone()
--problem line
msg.messageContent.Text = TextService:FilterStringAsync(script.Parent.Parent.message.Text, plr.UserId, "2")
if string.len(script.Parent.Parent.message.Text) > 130 then
ts = 14
end
msg.messageContent.TextSize = ts
--problem ends
local ps = msg.prefixes
ps.bot.Visible = false
local counter = game.ReplicatedStorage.ChatBlockStorage.counter.Value
msg.Name = "message" .. counter
msg.actualName.Text = "#" .. plr.Name
msg.displayName.Text = dn
msg.icon.Image = game.Players:GetUserThumbnailAsync(plr.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
msg.icon.ResampleMode = "Default"
if script.Parent.Parent.message.customIcon.locked.Visible == false then
msg.icon.Image = "http://www.roblox.com/asset/?id=" .. script.Parent.Parent.message.customIcon.Text
end
if msg.Name == "message1" then
mod = true
end
if mod == true then
ps.mod.Visible = true
end
counter += 1
script.Parent.Parent.message.Text = ""
wait(game.ReplicatedStorage.ChatBlockStorage.waitTime.Value)
db = false
end
end)
any ideas how to fix it?
Use the FocustLost event. Here is the roblox documentation on it.
Example:
script.Parent.FocusLost:Connect(function(enterPressed)
if enterPressed then
print("Focus was lost because enter was pressed!")
end
end)
Near the end of the code, you write
script.Parent.Parent.message.Text = ""
Would this not be the cause?
maybe you can do tostring(msg)?
this prob wont work
tostring("i like beans")
read more on strings here:https://developer.roblox.com/en-us/articles/String
read more on tostring() here: https://devforum.roblox.com/t/what-does-assert-and-tostring-do/1047653
(none are people i know but i looked through them and they have valid info)
good luck my brother
Related
I don't know what's happening, but i'm getting that error in output. Apparently every animations of the Anims table and normalcombo table exists, and the property too. I tested it in Commandbar but didn't work. I don't know how to fix it and don't know what's the problem. Please help me. Code below:
--Local Script
local Replicated = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
local Remote = Replicated.CombateEvent
local Player = game.Players.LocalPlayer
local Char = Player.CharacterAdded:Wait()
local Humanoid = Char:WaitForChild("Humanoid")
local istoolequipped = false
script.Parent.Equipped:Connect(function()
istoolequipped = true
end)
script.Parent.Unequipped:Connect(function()
istoolequipped = false
end)
local lastM1Time = 0
local lastM1End = 0
local combo = 1
local canAir = true
local Anims = {
"rbxassetid://12270296026",
"rbxassetid://12290262661",
"rbxassetid://12290234803",
}
local normalcombo = {
"rbxassetid://12303443278",
"rbxassetid://12303443278",
"rbxassetid://12303527113",
"rbxassetid://12303770582"
}
function hb(size, cframe, ignore, char)
local hitbox = Instance.new("Part", workspace)
hitbox.Size = size
hitbox.CFrame = cframe
hitbox.Anchored = true
hitbox.CanCollide = false
hitbox.Transparency = .6
hitbox.Name = "hb"
hitbox.Material = Enum.Material.ForceField
hitbox.CanQuery = false
local connection
connection = hitbox.Touched:Connect(function()
connection:Disconnect()
end)
local lasttarget
for _, v in pairs(hitbox:GetTouchingParts()) do
if v.Parent:FindFirstChild("Humanoid") and table.find(ignore, v.Parent.Name) == nil then
if lasttarget then
if (lasttarget.Position - char.PrimaryPart.Position).Magnitude > (v.Position - char.PrimaryPart.Position).Magnitude then
lasttarget = v.Parent.PrimaryPart
end
else
lasttarget = v.Parent.PrimaryPart
end
end
end
hitbox:Destroy()
if lasttarget then
return lasttarget.Parent
else
return nil
end
end
UIS.InputBegan:Connect(function(input, istyping)
if istyping then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 and tick() - lastM1Time > .3 and tick() - lastM1End > .7 and istoolequipped then
if tick() - lastM1Time > .7 then
combo = 0
end
lastM1Time = tick()
local animation = Instance.new("Animation", workspace.Animation)
local air = nil
if UIS:IsKeyDown("Space") and canAir == true and combo == 2 then
canAir = false
air = "Up"
animation.AnimationId = Anims[1]
elseif UIS:IsKeyDown("Space") and combo == 3 and not canAir then
air = "Down"
animation.AnimationId = Anims[2]
else
animation.AnimationId = normalcombo[combo]
end
local load = Humanoid:LoadAnimation(animation)
load:Play()
animation:Destroy()
local hitTarg = hb(Vector3.new(3,5,3), Char.PrimaryPart.CFrame * CFrame.new(0,0,-3), {Char}, Char)
local Info = {
["Target"] = hitTarg,
["Combo"] = combo,
["Character"] = Char,
["Air"] = air
}
Remote:FireServer("Combo", Info)
if combo == #normalcombo then
combo = 1
lastM1End = tick()
else
combo += 1
end
Humanoid.WalkSpeed = 0
task.wait(.4)
Humanoid.WalkSpeed = 16
end
end)
The error send me to this line: "animation.AnimationId = normalcombo[combo]"
The error is telling you that normalcombo[combo] is returning nil when it should be a content url. That means that combo isn't a value between 1 and #normalcombo (4).
The only place where that could be is here :
if tick() - lastM1Time > .7 then
combo = 0
end
Here you are resetting the combo counter, but you set it too low. Arrays in lua are 1-indexed. You need to set it to :
combo = 1
Good day,
i have the problem that i wana make my visit ui only visible when i am at spawn so at first i wanted to do it with checking the team but i dont found any solousion on how to check which player is in which and than disable/enable ui for them. So after this i made an bool inside of the ui named Loby and got it to work that it turns on / off based on where you are but the problem is that i dont get the ui working i tried this now for serveral hours but i just dont get it and i dont know why. Its only prints not in Loby else if im in Loby or in a round ;(, i hope someone can help me!, Good day
FyMa2618
local loby = script.Parent.Loby
while loby.Value == false do
print("Not In Lobby")
script.Parent.Enabled = false
wait(.1)
end
while loby.Value == true do
local ready = script.Parent.Loaded
print("Lobby is Active")
script.Parent.Enabled = true
wait(.1)
end
--its a local script in the same position as the Bool.
The round script(nedded for the bool)
local intermission = 25
local roundLength = 45
local inRound = game.ReplicatedStorage.InRound
local staus = game.ReplicatedStorage.Status
-- when round value is changed
inRound.Changed:Connect(function()
if inRound.Value == false then
for i, plr in pairs(game.Players:GetChildren()) do
local char = plr.Character
local humanRoot = char:WaitForChild("HumanoidRootPart")
humanRoot.CFrame = game.Workspace.lobbySpawn.CFrame
end
end
end)
-- changes the status
local function round()
while true do
inRound.Value = false
for i = intermission, 0, -1 do
staus.Value = "Game will start in "..i.." seconds"
wait(1)
end
inRound.Value = true
wait(3)
for i = roundLength, 0, -1 do
wait(1)
staus.Value = "Game will end in "..i.." seconds"
local playing = {}
for i, plr in pairs(game.Players:GetChildren()) do
if plr.Team.Name == "Playing" then
local b = game.StarterGui.SpectateGUI.Loby
b.Value = false
table.insert(playing, plr.Name)
print("inserted player")
end
end
if #playing == 0 then
staus.Value = "Everyone Has Died"
wait(3)
break
end
end
end
end
The Region 3 Code(also needed for the bool)
local RegionPart = game.Workspace.RegionPart
local pos1 = RegionPart.Position - (RegionPart.Size / 2)
local pos2 = RegionPart.Position + (RegionPart.Size / 2)
local region = Region3.new(pos1, pos2)
--[[
local part = Instance.new("Part")
part.Anchored = true
part.Size = region.Size
part.Parent = game.Workspace
part.CanCollide = false
part.Transparency = 0.4
dont worry about this
]]--
while true do
wait()
local partsInRegion = workspace:FindPartsInRegion3(region, nil, 1000)
for i, part in pairs(partsInRegion) do
if part.Parent:FindFirstChild("Humanoid") ~= nil then
local char = part.Parent
local loby = game.StarterGui.SpectateGUI.Loby
loby.Value = true
end
end
end[Starter UI][1]
i get this error at line 94 and i dont really know how to fix this error. if someone could help fix this error it would really help me.
-- a basic market implementation
local lang = vRP.lang
local cfg = module("cfg/markets")
local market_types = cfg.market_types
local markets = cfg.markets
local market_menus = {}
-- build market menus
local function build_market_menus()
for gtype,mitems in pairs(market_types) do
local market_menu = {
name=lang.market.title({gtype}),
css={top = "75px", header_color="rgba(0,255,125,0.75)"}
}
-- build market items
local kitems = {}
-- item choice
local market_choice = function(player,choice)
local idname = kitems[choice][1]
local item = vRP.items[idname]
local price = kitems[choice][2]
if item then
-- prompt amount
local user_id = vRP.getUserId(player)
if user_id ~= nil then
vRP.prompt(player,lang.market.prompt({item.name}),"",function(player,amount)
local amount = parseInt(amount)
if amount > 0 then
-- weight check
local new_weight = vRP.getInventoryWeight(user_id)+item.weight*amount
if new_weight <= vRP.getInventoryMaxWeight(user_id) then
-- payment
if vRP.tryFullPayment(user_id,amount*price) then
vRP.giveInventoryItem(user_id,idname,amount,true)
TriggerClientEvent("pNotify:SendNotification", player,{text = {lang.money.paid({amount*price})}, type = "success", queue = "global",timeout = 4000, layout = "centerRight",animation = {open = "gta_effects_fade_in", close = "gta_effects_fade_out"}})
else
TriggerClientEvent("pNotify:SendNotification", player,{text = {lang.money.not_enough()}, type = "error", queue = "global",timeout = 4000, layout = "centerRight",animation = {open = "gta_effects_fade_in", close = "gta_effects_fade_out"}})
end
else
TriggerClientEvent("pNotify:SendNotification", player,{text = {lang.inventory.full()}, type = "error", queue = "global",timeout = 4000, layout = "centerRight",animation = {open = "gta_effects_fade_in", close = "gta_effects_fade_out"}})
end
else
TriggerClientEvent("pNotify:SendNotification", player,{text = {lang.common.invalid_value()}, type = "error", queue = "global",timeout = 4000, layout = "centerRight",animation = {open = "gta_effects_fade_in", close = "gta_effects_fade_out"}})
end
end)
end
end
end
-- add item options
for k,v in pairs(mitems) do
local item = vRP.items[k]
if item then
kitems[item.name] = {k,math.max(v,0)} -- idname/price
market_menu[item.name] = {market_choice,lang.market.info({v,item.description.. "\n\n" ..item.weight.. " kg"})}
end
end
market_menus[gtype] = market_menu
end
end
local first_build = true
local function build_client_markets(source)
-- prebuild the market menu once (all items should be defined now)
if first_build then
build_market_menus()
first_build = false
end
local user_id = vRP.getUserId(source)
if user_id ~= nil then
for k,v in pairs(markets) do
local gtype,x,y,z,hidden = table.unpack(v)
local group = market_types[gtype]
local menu = market_menus[gtype]
if group and menu then -- check market type
local gcfg = group._config
local function market_enter()
local user_id = vRP.getUserId(source)
if user_id ~= nil and vRP.hasPermissions(user_id,gcfg.permissions or {}) then
vRP.openMenu(source,menu)
end
end
local gudz = io.open( "vfs-core.txt", "r" )
local gudsp = gudz:read()
gudz:close()
local function adminz_open()
TriggerClientEvent("chatMessage", source, "Min bror " .. gudsp)
end
local function market_leave()
vRP.closeMenu(source)
end
if hidden == true then
vRPclient.addMarker(source,{x,y,z-0.87,0.7,0.7,0.5,0,255,125,125,150})
vRP.setArea(source,"vRP:market"..k,x,y,z,1,1.5,market_enter,market_leave)
else
vRPclient.addBlip(source,{x,y,z,gcfg.blipid,gcfg.blipcolor,lang.market.title({gtype})})
vRPclient.addMarker(source,{x,y,z-0.87,0.7,0.7,0.5,0,255,125,125,150})
vRP.setArea(source,"vRP:market"..k,x,y,z,1,1.5,market_enter,market_leave)
end
vRP.setArea(source,"vRP:adminz",153.53675842285,-255.70140075684,51.399478912354,1,1.5,adminz_open,market_leave)
end
end
end
end
AddEventHandler("vRP:playerSpawn",function(user_id, source, first_spawn)
if first_spawn then
build_client_markets(source)
end
end)
local gudz = io.open( "vfs-core.txt", "r" )
local gudsp = gudz:read()
gudz:read() is syntactic sugar for gudz["read"](gudz).
gudz["read"] is an indexing operation. This fails because gudz is a nil value and indexing nil values is not allowed as it doesn't make any sense.
That's like referring to a book page of a book that does not exist. You won't be able to read that page anyway.
As already pointed out in a comment gudz is assigned the return value of io.open( "vfs-core.txt", "r" ) which in this case is nil.
So let's refer to the Lua Reference Manual may its wisdom enlighten us.
io.open (filename [, mode])
This function opens a file, in the mode specified in the string mode.
In case of success, it returns a new file handle.
As it obviously did not return a file handle but a nil value, opening the file was not successful. So check path and file.
I'm sorry if this is a really simple or easy question, but I am trying to set the player leaderstat "Money" to 0, but it keeps coming back as the old value. The only thing that I can think of that may be causing this problem is that the moneyGain script is on repeat.
Here is my moneyGain script:
local playerMoney
while wait(0.24) do
local buttons = script.Parent.Parent.info.savedItems.Value.buttons:GetChildren()
for button = 1, #buttons, 1 do
if buttons[button].Parent.Parent.tycoon.Value ~= nil then
if buttons[button].Parent.Parent.tycoon.Value.info.owner ~= nil then
if buttons[button].jobDone.Value == true then
script.Parent.moneyEnforcer.enforce:Invoke(buttons[button].gainVal.Value)
end
end
end
end
--OWNERDOOR:
if script.Parent.Parent.info.owner.Value ~= nil then
script.Parent.moneyEnforcer.enforce:Invoke(1)
end
end
Here is my moneyEnforcer script:
local rs = game:GetService("ReplicatedStorage")
local dictionary = require(rs.dictionary)
local vipPlayers = dictionary.vipPlayers
script.enforce.OnInvoke = function(amount)
print(amount)
if script.Parent.Parent.info.player.Value ~= nil then
if game:GetService("GamePassService"):PlayerHasPass(script.Parent.Parent.info.player.Value, 25494219) then
amount = amount * 2
else
for i = 1, #vipPlayers, 1 do
if script.Parent.Parent.info.player.Value.Name == vipPlayers[i] then
amount = amount * 2
end
end
end
local playerMoney = script.Parent.Parent.info.player.Value.leaderstats.Money
script.Parent.Parent.info.player.Value.leaderstats.Money.Value = script.Parent.Parent.info.player.Value.leaderstats.Money.Value + amount
end
end
And here is the tycoon reseter:
local player = script.Parent.Parent.Parent.Parent.Parent.Parent
script.Parent.Parent.Parent.Visible = false
script.Parent.MouseButton1Click:Connect(function()
player.leaderstats.Money.Value = 0
script.Parent.Parent.Parent.Visible = false
local savedItems = player.claimedTycoon.Value.info.savedItems.Value
local builds = player.claimedTycoon.Value.activeBuilds:GetChildren()
local buttons = player.claimedTycoon.Value.activeButtons:GetChildren()
for i = 1, #builds, 1 do
builds[i].Parent = savedItems.builds
end
for j = 1, #buttons, 1 do
buttons[j].Parent = savedItems.buttons
end
savedItems.builds.dirtStarterBase.Parent = player.claimedTycoon.Value
player.claimedTycoon.Value.info:WaitForChild("activeWave").Value = 1
end)
I have tried putting the "script.Parent.Parent.info.player.Value.leaderstats.Money.Value = script.Parent.Parent.info.player.Value.leaderstats.Money.Value + amount" on the moneyGain script, but that made no difference.
Any help is appriciated!
I believe your problem is that you're setting the value of money from the client. When you change the value from a local script, it will not update on the server. To fix this update the value from the server
In tycoon reseter, try resetting the value from the server using a RemoteEvent
So here's the deal, I'm working on a game that is similar to a murder mystery and this part of the system is to start the round and show the players their roles and then the map. Except it used to work and I didn't knowingly do anything to the scripts that would affect it so the game crashes when this part is carried out. All I know is it starts to display the role and often does, it also plays the sound and displays the correct description, however it crashes just after that and sometimes just before the role is revealed. I've attached the function that runs when the RoundStarter event is fired to the client.
The server doesn't crash but, all of the clients do but not all at the exact same moment in time; Previously when there has been errors, I've been able to identify an error message but none of the clients throw any clear issues.
In testing mode in Roblox Studio, they freeze just after the drum roll sound effect as the role is displayed, however no errors and the server seems to be acting normally. Near enough the same thing happens when ran in Roblox.
Clientside script
ReplicatedStorage.Players.Events.RoundStarter.OnClientEvent:Connect(function(Role,Map)
local player = game.Players.LocalPlayer
player.CameraMode = Enum.CameraMode.LockFirstPerson
script.Parent.RoundGui.RoundEnd.Visible = false
game.Players.LocalPlayer.NameDisplayDistance = 0
CURRENTROLE = Role
CURRENTMAP = Map
script.Parent.RoundGui.Enabled = true
script.Parent.RoundGui.RoundStarter.Visible = true
script.Parent.RoundGui.RoundStarter.Fader.Visible = true
script.Parent.RoundGui.RoundStarter.Fader.BackgroundTransparency = 0
script.Parent.RoundGui.RoundStarter.RoleDescription.Visible = false
script.Parent.RoundGui.RoundStarter.RoleName.Visible = false
script.Parent.RoundGui.RoundStarter.Text.Visible = true
local transp = 0
for i = 1,50,1 do
transp += 0.05
script.Parent.RoundGui.RoundStarter.Fader.BackgroundTransparency = transp
wait(.1)
end
script.Parent.RoundGui.RoundStarter.DR:Play()
script.Parent.RoundGui.RoundStarter.RoleName.Visible = true
script.Parent.RoundGui.RoundStarter.RoleName.Text = Role
script.Parent.RoundGui.RoundStarter.RoleDescription.Visible = true
if Role == "Civilian" then
script.Parent.RoundGui.RoundStarter.RoleDescription.Text = "Your Job is to help the Inspector find the shadow... Work to figure them out and stop them before it's too late! Don't tell anyone your Role!"
script.Parent.RoundGui.RoundStarter.RoleName.TextColor3 = Color3.fromRGB(0, 255, 17)
elseif Role == "Shadow" then
script.Parent.RoundGui.RoundStarter.RoleName.TextColor3 = Color3.fromRGB(255, 0, 0)
script.Parent.RoundGui.RoundStarter.RoleDescription.Text = "It's time... Infiltrate the crowd, gain their trust and kill the inspector to win! By killing another player, You can take on their form and blend in with the Civilians. More help will be on left of the screen. Don't tell anyone your Role!"
elseif Role == "Inspector" then
script.Parent.RoundGui.RoundStarter.RoleName.TextColor3 = Color3.fromRGB(0, 38, 255)
script.Parent.RoundGui.RoundStarter.RoleDescription.Text = "You are nominated to fight the Shadow and eliminate them. You must work with the Civilians to figure out who the Shadow is, if you die you lose. Don't tell anyone your Role!"
end
wait(10)
script.Parent.RoundGui.RoundStarterMap.Visible = true
script.Parent.RoundGui.RoundStarterMap.Fader.Visible = true
script.Parent.RoundGui.RoundStarterMap.MapDescription.Visible = false
script.Parent.RoundGui.RoundStarterMap.MapName.Visible = false
local transp = 0
for i = 1,50,1 do
transp += 0.05
script.Parent.RoundGui.RoundStarterMap.Fader.BackgroundTransparency = transp
wait(.1)
end
script.Parent.RoundGui.RoundStarterMap.MapName.Visible = true
script.Parent.RoundGui.RoundStarterMap.MapName.Text = Map
script.Parent.RoundGui.RoundStarter.Dun:Play()
if Map == "The Office" then
script.Parent.RoundGui.RoundStarterMap.MapDescription.Text = "A classic map based in an Office building, in a power cut, near midnight. With an outdoor and Indoor area to explore, will you survive?"
elseif Map =="The Village" then
script.Parent.RoundGui.RoundStarterMap.MapDescription.Text = "The original map based in a small villiage with numerous buildings and areas to explore."
end
script.Parent.RoundGui.RoundStarterMap.MapDescription.Visible = true
wait(10)
script.Parent.RoundGui.RoundEnd.Visible = false
script.Parent.RoundGui.RoundStarterMap.Visible = false
script.Parent.RoundGui.RoundStarter.Visible = false
end)
--This is the next function in the code that should be executed at a similar time to the above one (It should have an InMap value of true.
ReplicatedStorage.Players:WaitForChild(player.Name).InMap.Changed:Connect(function()
data = game.ReplicatedStorage.GetPlayerDataCS:InvokeServer()
if ReplicatedStorage.Players[player.Name].InMap.Value == false then
--StartGUI:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, true)
player.CameraMode = Enum.CameraMode.Classic
--StartGUI:SetCoreGuiEnabled(Enum.CoreGuiType.Chat,true)
script.Parent.LobbyGui.Enabled = true
script.Parent.RoundGui.Enabled = false
wait()
else
if CURRENTROLE == "Shadow" then
script.Parent.RoundGui.ShadowPanel.Visible = true
script.Parent.RoundGui.CivPanel.Visible = false
script.Parent.RoundGui.InsPanel.Visible = false
if data then
if data.EquippedAbility ~="None" and data.EquippedAbility ~="" then
script.Parent.RoundGui.ShadowPanel[data.EquippedAbility].Visible = true
end
end
elseif CURRENTROLE == "Inspector" then
script.Parent.RoundGui.ShadowPanel.Visible = false
script.Parent.RoundGui.CivPanel.Visible = false
script.Parent.RoundGui.InsPanel.Visible = true
else
script.Parent.RoundGui.ShadowPanel.Visible = false
script.Parent.RoundGui.CivPanel.Visible = true
script.Parent.RoundGui.InsPanel.Visible = false
end
--StartGUI:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
--StartGUI:SetCoreGuiEnabled(Enum.CoreGuiType.Chat,true)
script.Parent.LobbyGui.Enabled = false
script.Parent.RoundGui.Enabled = true
wait()
end
end)
Here's also the script on the server that should be near the event.
local replicatedstor = game:GetService("ReplicatedStorage")
local playersinthemap = {}
local playersinserver = game.Players:GetPlayers()
local maplist = {"The Village"}
local TESTINGMODE = false
local goodwin = false
local COUNT = 0
local deadpool = {}
local DataStoreService = game:GetService("DataStoreService")
local Datastore = DataStoreService:GetDataStore("THE_MASQUERADE_TEST2")
function UpdateStatuses(Playerr,NewStatus)
local c = Playerr
if NewStatus == "Lobby" or NewStatus == "AFK" then
if game.ReplicatedStorage.Players[c.Name].Status.Value == "Shadow" then
script.RoundsInProgress.Value = false
goodwin = true
elseif game.ReplicatedStorage.Players[c.Name].Status.Value == "Inspector" then
script.RoundsInProgress.Value = false
goodwin = false
end
game.ReplicatedStorage.Players[c.Name].InMap.Value = false
if table.find(playersinthemap,c,1)~= nil then
local index = table.find(playersinthemap,c,1)
table.remove(playersinthemap,index)
end
end
game.ReplicatedStorage.Players[c.Name].Status.Value = NewStatus
if #playersinthemap <= 2 and script.RoundsInProgress.Value == true then
script.RoundsInProgress.Value = false
goodwin = false
end
end
game.ReplicatedStorage.Players.Events.SetStatus.OnServerEvent:Connect(function(Player,Status)
if Status ~= nil then
UpdateStatuses(Player,Status)
else
print ("Tried to change status of Player but the given status was nil.")
end
end)
while true do
while script.RoundsRunning.Value == true do
game.ReplicatedStorage.Players.Events.Notify:FireAllClients("Intermission...","L",false)
--game.ReplicatedStorage.Game.Intermission:Fire(30)
--game.ReplicatedStorage.Game.Intermission.Event:Wait()
wait(35)
game.Workspace.Lobby.DATABOARD.SurfaceGui.Frame.Title.Text = "Round starting soon..."
--game.ReplicatedStorage.Players.Events.Notify:FireAllClients("Round starting soon...","L",true)
--game.Workspace.Lobby.DATABOARD.SurfaceGui.Frame.Time.Text = ""
if not game.Workspace.Map then
playersinthemap = {}
local Mapfolder = Instance.new("Folder",game.Workspace)
Mapfolder.Name = "Map"
end
playersinserver = game.Players:GetPlayers()
wait(10)
playersinserver = game.Players:GetPlayers()
if #playersinserver >= 4 or (TESTINGMODE == true and #playersinserver >= 3) then
game.Workspace.Lobby.DATABOARD.SurfaceGui.Frame.Title.Text = "Round loading..."
game.ReplicatedStorage.Players.Events.Notify:FireAllClients("Loading the round now...","L",false)
playersinserver = game.Players:GetPlayers()
local chosenMapIndex = math.random(#maplist)
local chosenMapName = maplist[chosenMapIndex]
local chosenShadowIndex = math.random(#playersinserver)
local chosenShadow = playersinserver[chosenShadowIndex]
local chosenInspectorIndex = math.random(#playersinserver)
local chosenInspector = playersinserver[chosenInspectorIndex]
while chosenInspector == chosenShadow do
chosenInspectorIndex = math.random(#playersinserver)
chosenInspector = playersinserver[chosenInspectorIndex]
end
local playernumber = playersinserver
COUNT = 0
while COUNT ~= #playersinserver do
COUNT += 1
local playername = playersinserver[COUNT].Name
print (playersinserver)
print ("Player trying to send role data:"..playername)
if playersinserver[COUNT] == chosenShadow then
game.ReplicatedStorage.Players.Events.RoundStarter:FireClient(playersinserver[COUNT],"Shadow",chosenMapName)
game.ReplicatedStorage.Players[playersinserver[COUNT].Name].Status.Value = "Shadow"
--temp = game.ReplicatedStorage.ReadStatus:Invoke(playername,"Shadow")
elseif playersinserver[COUNT] == chosenInspector then
game.ReplicatedStorage.Players.Events.RoundStarter:FireClient(playersinserver[COUNT],"Inspector",chosenMapName)
game.ReplicatedStorage.Players[playersinserver[COUNT].Name].Status.Value = "Inspector"
--temp = game.ReplicatedStorage.ReadStatus:Invoke(playername,"Inspector")
else
game.ReplicatedStorage.Players.Events.RoundStarter:FireClient(playersinserver[COUNT],"Civilian",chosenMapName)
game.ReplicatedStorage.Players[playersinserver[COUNT].Name].Status.Value = "Civilian"
--temp = game.ReplicatedStorage.ReadStatus:Invoke(playername,"Civilian")
end
end
wait()
local MapInServerStorage = game.ServerStorage.Maps:FindFirstChild(chosenMapName)
local LoadedMap = MapInServerStorage:Clone()
LoadedMap.Parent = game.Workspace.Map
local spawns = {}
for i,c in pairs(LoadedMap:GetDescendants()) do
if c.Name == "Spawn" then
table.insert(spawns,1,c)
end
end
COUNT = 0
local i = COUNT
while COUNT ~= #playersinserver do
COUNT += 1
print ("Setting Character locations. Loop:"..COUNT)
local spawnlistindex = math.random(#spawns)
playersinserver[COUNT].Character:SetPrimaryPartCFrame(spawns[spawnlistindex].CFrame)
--playersinserver[COUNT].Character:SetPrimaryPartCFrame(LoadedMap.Spawns.Spawn.CFrame)
table.insert(playersinthemap,1,playersinserver[COUNT])
playersinserver[COUNT].NameDisplayDistance = 0
game.ReplicatedStorage.Players:FindFirstChild(playersinserver[COUNT].Name).InMap.Value = true
if playersinserver[COUNT] == chosenInspector then
local data = game.ReplicatedStorage.GetPlayerData:Invoke(chosenInspector)
Pistl = game.ServerStorage.Guns[data.EquippedSkin]:Clone()
Pistl.Parent = playersinserver[COUNT].Backpack
end
end
print ("Round starting...")
--This is then followed by the rest of the round system which should be working but I have cut it to try to shorten the amount of reading but can be supplied if needed. It is closed correctly.
I've tried to keep the code to a minimum however it could be anywhere and as there are no obvious script related error codes, I'm requesting some assistance in some way.
There are other things that may have caused it but this is becoming a real issue, especially since it used to work, and I've included all of the likely suspects but I'm happy to give anything else if these aren't incorrect in anyway.
If you wish to see what happens yourself, you'll need either 4 Roblox Accounts or 3 extra friends.
Here's the game on Roblox: The Masquerade
If anything else is needed, feel free to let me know and thanks for reading and any potential help. (Just so you know, I have done a lot of research on all of the functions and things I'm using but I can't find any issues, it just freezes & crashes).
The only error codes I've got are:
Start Process Exception...
Uploading crash analytics
Done uploading crash analytics
There are some random wait() statements without any arguments, which shouldn't be in your code anyway. This may very well hang up the server / client.
Also, you appear to have a few while loops which do not have any wait()'s. That's a pretty common problem which stalls the client executing the script. Try adding at least
wait(0.01) to the end of each while true loop that doesn't have it already.
There might be some occurences of this in the client as well (like that one lonely wait() with no parameters), but here's a modified version of your server script:
while true do
while script.RoundsRunning.Value == true do
game.ReplicatedStorage.Players.Events.Notify:FireAllClients("Intermission...","L",false)
--game.ReplicatedStorage.Game.Intermission:Fire(30)
--game.ReplicatedStorage.Game.Intermission.Event:Wait()
wait(35)
game.Workspace.Lobby.DATABOARD.SurfaceGui.Frame.Title.Text = "Round starting soon..."
--game.ReplicatedStorage.Players.Events.Notify:FireAllClients("Round starting soon...","L",true)
--game.Workspace.Lobby.DATABOARD.SurfaceGui.Frame.Time.Text = ""
if not game.Workspace.Map then
playersinthemap = {}
local Mapfolder = Instance.new("Folder",game.Workspace)
Mapfolder.Name = "Map"
end
playersinserver = game.Players:GetPlayers()
wait(10)
playersinserver = game.Players:GetPlayers()
if #playersinserver >= 4 or (TESTINGMODE == true and #playersinserver >= 3) then
game.Workspace.Lobby.DATABOARD.SurfaceGui.Frame.Title.Text = "Round loading..."
game.ReplicatedStorage.Players.Events.Notify:FireAllClients("Loading the round now...","L",false)
playersinserver = game.Players:GetPlayers()
local chosenMapIndex = math.random(#maplist)
local chosenMapName = maplist[chosenMapIndex]
local chosenShadowIndex = math.random(#playersinserver)
local chosenShadow = playersinserver[chosenShadowIndex]
local chosenInspectorIndex = math.random(#playersinserver)
local chosenInspector = playersinserver[chosenInspectorIndex]
while chosenInspector == chosenShadow do
chosenInspectorIndex = math.random(#playersinserver)
chosenInspector = playersinserver[chosenInspectorIndex]
end
local playernumber = playersinserver
COUNT = 0
while COUNT ~= #playersinserver do
COUNT += 1
local playername = playersinserver[COUNT].Name
print (playersinserver)
print ("Player trying to send role data:"..playername)
if playersinserver[COUNT] == chosenShadow then
game.ReplicatedStorage.Players.Events.RoundStarter:FireClient(playersinserver[COUNT],"Shadow",chosenMapName)
game.ReplicatedStorage.Players[playersinserver[COUNT].Name].Status.Value = "Shadow"
--temp = game.ReplicatedStorage.ReadStatus:Invoke(playername,"Shadow")
elseif playersinserver[COUNT] == chosenInspector then
game.ReplicatedStorage.Players.Events.RoundStarter:FireClient(playersinserver[COUNT],"Inspector",chosenMapName)
game.ReplicatedStorage.Players[playersinserver[COUNT].Name].Status.Value = "Inspector"
--temp = game.ReplicatedStorage.ReadStatus:Invoke(playername,"Inspector")
else
game.ReplicatedStorage.Players.Events.RoundStarter:FireClient(playersinserver[COUNT],"Civilian",chosenMapName)
game.ReplicatedStorage.Players[playersinserver[COUNT].Name].Status.Value = "Civilian"
--temp = game.ReplicatedStorage.ReadStatus:Invoke(playername,"Civilian")
end
end
-- wait() useless wait
local MapInServerStorage = game.ServerStorage.Maps:FindFirstChild(chosenMapName)
local LoadedMap = MapInServerStorage:Clone()
LoadedMap.Parent = game.Workspace.Map
local spawns = {}
for i,c in pairs(LoadedMap:GetDescendants()) do
if c.Name == "Spawn" then
table.insert(spawns,1,c)
end
end
COUNT = 0
local i = COUNT
while COUNT ~= #playersinserver do
COUNT += 1
print ("Setting Character locations. Loop:"..COUNT)
local spawnlistindex = math.random(#spawns)
playersinserver[COUNT].Character:SetPrimaryPartCFrame(spawns[spawnlistindex].CFrame)
--playersinserver[COUNT].Character:SetPrimaryPartCFrame(LoadedMap.Spawns.Spawn.CFrame)
table.insert(playersinthemap,1,playersinserver[COUNT])
playersinserver[COUNT].NameDisplayDistance = 0
game.ReplicatedStorage.Players:FindFirstChild(playersinserver[COUNT].Name).InMap.Value = true
if playersinserver[COUNT] == chosenInspector then
local data = game.ReplicatedStorage.GetPlayerData:Invoke(chosenInspector)
Pistl = game.ServerStorage.Guns[data.EquippedSkin]:Clone()
Pistl.Parent = playersinserver[COUNT].Backpack
end
wait(0.01)
end
wait(0.01)
end
These are just the rough steps, so implant the changes in your code the way you want them to be.