#regag
23 messages · Page 1 of 1 (latest)
uhhh. nvm
local function sendNotification(player, message)
game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", {
Text = message,
Color = Color3.new(1, 1, 1),
Font = Enum.Font.SourceSans,
FontSize = Enum.FontSize.Size24,
TextStrokeTransparency = 0.75,
TextTransparency = 0.25,
TextStrokeColor = Color3.new(0, 0, 0),
TextColor = Color3.new(1, 1, 1),
LocalPlayer = player
})
end
local function assignRolesAndNotify()
local players = game:GetService("Players"):GetPlayers()
if #players > 0 then
to be the Traitor
local traitorIndex = math.random(1, #players)
local traitor = players[traitorIndex]
sendNotification(traitor, "You're the traitor!")
for i, player in ipairs(players) do
if i ~= traitorIndex then
sendNotification(player, "You're a scientist")
end
end
end
end
while true do
assignRolesAndNotify()
wait(18)
end``` Idk why this script dont work guys
dont be mad
im developing as a hobby
put wait before calling the function
Are you trying to make it a comment when you say “to be the Traitor” above the defining variables? if so you need -- to be the Traitor to mark it as a comment so the script isn’t trying to run that part. Fix your loop too, it’s infinite.
Also, LocalPlayer is not valid when trying to use SetCore(“ChatMakeSystemMessage”) as SetCore only takes message properties (size, color, font).
you need time for players to connect to server
local function sendNotification(player, message)
game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", {
Text = message,
Color = Color3.new(1, 1, 1),
Font = Enum.Font.SourceSans,
FontSize = Enum.FontSize.Size24,
TextStrokeTransparency = 0.75,
TextTransparency = 0.25,
TextStrokeColor = Color3.new(0, 0, 0),
TextColor = Color3.new(1, 1, 1),
LocalPlayer = player
})
end
local function assignRolesAndNotify()
local players = game:GetService("Players"):GetPlayers()
if #players > 0 then
to be the Traitor
local traitorIndex = math.random(1, #players)
local traitor = players[traitorIndex]
sendNotification(traitor, "You're the traitor!")
for i, player in ipairs(players) do
if i ~= traitorIndex then
sendNotification(player, "You're a scientist")
end
end
end
end
while true do
assignRolesAndNotify()
wait(18)
end``` this?
sorry, but i knownothing about coding
Is this a LocalScript?
nope
nope
you can connect this to when a player is added once
Okay, well you’re using SetCore(“”) which can only be used in a local script.
so put the localscript in starterchar or starterplayer?
It should go in StarterPlayerScripts (inside StarterPlayer)
ok..
doesnt work
** You are now Level 10! **
No, you shouldn’t put your entire script inside of StarterPlayerScripts, you need to use a RemoteEvent in ReplicatedStorage to have the server communicate properly
...