Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

suicide script for certain player only? (redone)

Asked by 7 years ago
Edited 7 years ago

so i wanted to make a script that kills the chatter whenever he or she said a specific thing if they were a specific person say for example, Player 1 said pwnt then player 2 said pwnt, then player 3 but then only player 1 would get killed because he was a specific person who chatted something very specific but it wont work, at least not properly.

function onChatted(msg, speaker)
local source = string.lower(speaker.Name)
local msg = string.lower(msg)
local playr = game.Players.LocalPlayer
local ad = playr:GetFullName()

if msg == "get rekt" then
if ad == "Player1, Player2, Player 3" then
    speaker.Character.Head:remove() -- 
end end
end

function onPlayerEntered(newPlayer)
 newPlayer.Chatted:connect(function(msg) onChatted(msg, newPlayer) 
end) end

game.Players.ChildAdded:connect(onPlayerEntered)

function onChatted(msg, speaker) end

1 answer

Log in to vote
-2
Answered by 7 years ago
Edited 7 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

This is a local script in StarterGui

function onChatted(msg, speaker)
local source = string.lower(speaker.Name)
local msg = string.lower(msg)
local player = game.Players.LocalPlayer
local ad = player:GetFullName()

if msg == "get rekt" then
if ad == "Player1" then --you only need to put player1
    speaker.Character.Head:remove() -- 
end end
end

function onPlayerEntered(newPlayer)
 newPlayer.Chatted:connect(function(msg) onChatted(msg, newPlayer) 
end) end

game.Players.ChildAdded:connect(onPlayerEntered)

function onChatted(msg, speaker) end

This should fix it!

0
didnt fix D: is it a local script or server script tommytherox 5 — 7y
Ad

Answer this question