#Jumpscare Command (i need PlayerAdded help)

27 messages · Page 1 of 1 (latest)

slow vapor
#

It's supposed to make who ever writes "!jumpscare" have a Gui pop up but it does nothing (no errors in output) i need help making it understand what i mean by player with the PlayerAdded thing but idk how to implement it, this is a local script.

local Players = game:GetService("Players")
local playCommand = "!jumpscare"
local Gui = game:GetService("StarterGui").ScreenGui.fgaaimage

local function onPlayerAdded(player)
print("player has been added")
end

local function onPlayerChatted(player, message)
if message:sub(1, playCommand:len()):lower() == playCommand then
Gui.Visible = true
wait(10)
Gui.Visible = false
end
end

player.Chatted:Connect(function(message, _recipient)
onPlayerChatted(player, message)
end)

Players.PlayerAdded:Connect(onPlayerAdded)

golden mason
#

This will only run once if you're using PlayerAdded

slow vapor
golden mason
#

An event that's relative to your chatBox

#

if the player will type "!jumpscare" in the chatBox it'll pop up the Gui

slow vapor
golden mason
#

Idk

slow vapor
#

god if you dont even know

golden mason
#

I mean, I know PlayAdded only runs when a player is added

#

which only runs the function once

#

So, incase you're going to chat you need to be faster than a script

deep dew
#
local Players = game:GetService("Players")
local Chat = game:GetService("Chat")
local StarterGui = game:GetService("StarterGui")

-- Function to handle when a chat message is sent
local function onPlayerChatted(player, message)
    if message == "!jumpscare" then
        -- Create and display the GUI
        local gui = Instance.new("ScreenGui")
        gui.Parent = player.PlayerGui
        
        -- Add UI elements to the gui (e.g., an image or text)
        -- ...
        
        -- Remove the GUI after a specified time (if desired)
        wait(5) -- Change the number of seconds here as needed
        gui:Destroy()
    end
end

-- Connect the player chatting event
Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(message)
        onPlayerChatted(player, message)
    end)
end)
#

place it in starterplayerscripts

#

or startergui

slow vapor
lilac grottoBOT
#

studio** You are now Level 1! **studio

slow vapor
#

it dosnt print

#

i found one that does print but dosnt work with the gui wich is weird i can show you

#

(also my headphones broke thats why it took long time)

#

this one prints

#

only when its in serverscriptservice doe

#

i got it to work i was trying to activate it from StarterGui and not the PlayerGui inside the player 🤦‍♂️

#

here is the working script

golden mason
#

Yay