#regag

23 messages · Page 1 of 1 (latest)

bronze dome
#

make me a script so every 18 seconds, a player will receive a notification in the chat that only the player can see. It says "You're the traitor!". While the rest of the players will receive a notification in the chat that only them can see that says "You're a scientist"

#

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

ancient urchin
#

put wait before calling the function

wild hamlet
#

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).

ancient urchin
#

you need time for players to connect to server

bronze dome
#
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

wild hamlet
#

Is this a LocalScript?

bronze dome
#

nope

bronze dome
ancient urchin
#

you can connect this to when a player is added once

wild hamlet
#

Okay, well you’re using SetCore(“”) which can only be used in a local script.

bronze dome
wild hamlet
#

It should go in StarterPlayerScripts (inside StarterPlayer)

bronze dome
#

ok..

sonic flareBOT
#

studio** You are now Level 10! **studio

wild hamlet
#

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

bronze dome
#

...