How can i set some names to be able to type a command in roblox to kill other people - roblox

i am making a tycoon that's getting around and i want admin powers, that reminds me of Austin powers. anyways, i need something to let me type :kill [name] or something like that to be able to kill anybody! please help, i only found 1 answer to some one else who asked this but i couldn't understand, i tried to find right syntax, i couldn't figure it out.
I found this though, but it only does it for that person, maybe something like kill/..player.Name?
game.Players.PlayerAdded:connect(function(player) --this gets the player that connected
player.Chatted:connect(function(message) --this function executes when the player type into chat
--commands are here
if player.Name == "AlexanderYar" or player.Name == "nathancain" or player.Name == "block100000" then
if message == "kill/me" then
player.Character.Head:remove()
end
if message == "ff/me" then
if player.Character:findFirstChild("ForceField") then
player.Character.ForceField:Destroy()
end
Instance.new("ForceField").Parent = player.Character
end
if message == "unff/me" then
if player.Character:findFirstChild("ForceField") then
player.Character.ForceField:Destroy()
end
end
end
end)
end)

Original code was this:
if message == "kill/me" then
player.Character.Head:remove()
end
Replace with this code:
if string.sub(message,1,5) == "kill/" then
local targetName = string.sub(message,6)
if targetName == "me" or targetName == "Me" then
player.Character.Head:Destroy()
else
for i,v in ipairs(game.Players:GetPlayers()) do
if string.lower(v.Name) == string.lower(targetName) and v.Character and v.Character:FindFirstChild("Head") then
v.Character.Head:Destroy()
end
end
end
end
This should now work for killing other players!

Related

End Expected Near <EOF> even though The Script Works FIne What Am I doing Wrong

End Expected Near even though The Script Works FIne What Am I doing Wrong i tried to fix it but it creates more errors
--Prison life Loop Bring Induvidual
local Player = GetPlayer(Arg2)
if Player ~= nil then
Notify("Looping bring "..Player.Name, Color3.fromRGB(0, 255, 0), "Success")
States.PlayerToLoopBring = Player
States.LoopBring = true
repeat wait()
pcall(function()
if States.LoopBring and game.Players[States.PlayerToLoopBring.Name] then
local savedcf = GetPos()
Teleport(States.PlayerToLoopBring, GetPos())
game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = savedcf
end
end)
until States.LoopBring == false
end
Please Tell Me What Is wrong with this script, It is for when someone Is messing with me or killing everybody In the lobby i will teleport them off the map forever

Roblox remoteevents change value

local script
function Click(player)
if game.Workspace.Folder.Value == 0 then local num = 1
elseif game.Workspace.Folder.Value == 1 then local num = 0
game.ReplicatedStorage.Test:FireServer(player ,num)
end
script.Parent.ClickDetector.MouseClick:connect(Click)
end
server script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
ReplicatedStorage.Test.OnServerEvent:Connect(function(player ,num)
if player:GetRankInGroup(1) > 248 then
game.Workspace.Folder.Value = num
else
end
end
)
Doesn't work at all, tried testing if it even connects by printing stuff.
You have a bunch of issues.
1. LocalScripts only run in a few locations, and the Workspace isn't one of them.
Based on your code, I'm assuming this LocalScript is a child of a ClickDetector in the Workspace.
See the docs for LocalScripts :
A LocalScript will only run Lua code if it is a descendant of one of the following objects:
A Player’s Backpack, such as a child of a Tool
A Player’s character model
A Player’s PlayerGui
A Player’s PlayerScripts.
The ReplicatedFirst service
So you need to move the LocalScript to a location where it will actually run, then update the path to the ClickDetector.
-- find the detector in the Workspace
local detector = game.Workspace.Part.ClickDetector
detector.MouseClick:Connect(Click)
2. The connection is inside a function that never gets called.
This looks like a typo, but the line where the MouseClick signal is connected to happens inside the Click function, not outside. So effectively, the Click function is declared and never called by anything. You need to move it outside the last end
3. Variables declared using `local` are only accessible at the level (or deeper) that they are declared at.
Let me annotate your code to highlight what's happening...
local function Click(player)
if game.Workspace.Folder.Value == 0 then
local num = 1
-- num stops existing here and Test is never fired
elseif game.Workspace.Folder.Value == 1 then
local num = 0
game.ReplicatedStorage.Test:FireServer(num)
-- Test is fired with a value of 0 only when Folder.Value equals 1
end
end
local detector = game.Workspace.Part.ClickDetector
detector.MouseClick:Connect(Click)
To fix this, you need to move the local num declaration to a higher scope so it is encapsulates the if-statement. Then you need to make sure that the Remote event is fired in both cases, so you should move it outside the if-statement...
function Click(player)
-- define num
local num
if game.Workspace.Folder.Value == 0 then
num = 1
else --if game.Workspace.Folder.Value == 1 then
num = 0
end
-- fire the RemoteEvent
game.ReplicatedStorage.Test:FireServer(num)
end
local detector = game.Workspace.Part.ClickDetector
detector.MouseClick:Connect(Click)
4. (Nit-pick) Bad tabbing in your server Script creates confusion
This is not something you need to fix, but as atomfrog pointed out, nothing is happening in your Script's else block. It is unnecessary to have it at all, and it looks like you tried to use end to escape from the Script, but all you've done is indented your if-statement incorrectly. If you want to escape or for nothing to happen, use return, or don't have an else block.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
ReplicatedStorage.Test.OnServerEvent:Connect( function(player, num)
local specialGroupId = 1
local lowestPermissionLevel = 248
if player:GetRankInGroup(specialGroupId) > lowestPermissionLevel then
game.Workspace.Folder.Value = num
end
end)
maybe it doesn't work because you have nothing after the else

MATLAB String Input If statment

I'm trying to make a program that asks a yes or no question. Based on that answer the program will continue or terminate. I keep getting an error since the arrays don't have the same dimension. I tried to use strcmp() but failed. I don't understand how true or false will help me discriminate between different words and capitalization. (Do I have to test each letter?) I want the program to continue if the input is any of these words 'yes','YES','Yes','y' and quit if the input is 'no','NO','No','n' I really want to understand, the == feels wrong somehow.
Thank You
ZZ=input('Do you want to know when you''ll turn 100?: ', 's');
NN={'no','NO','No','n'}
YY={'yes','YES','Yes','y'}
XX=strcmp(ZZ(NN),ZZ(YY)); %I thought this line would let MATLAB know everything is ok
if ZZ=='no' || ZZ=='NO' || ZZ=='No' || ZZ=='nO' || ZZ=='n'
disp('Thank You.')
disp('Come again.')
elseif ZZ=='yes' || ZZ=='YES'|| ZZ=='Yes'|| ZZ=='y'
x=input('Enter your age: '); %x is your age.
.....
I think if you need your program to run more than once, you need a for or while loop.
zz = 'yes';
while strcmpi(zz(1),'y')
x = input('Enter your age: ');
zz = input('Do you want to know when you''ll turn 100?: ', 's');
end

How to avoid enter any i and j value when numeric input is required in matlab

Consider I have
a = input(value = );
how can I prevent user from enter i and j as the input values. I would like to have a code some thing like tat
if a == any value involves i and j
then break or terminate
and prompt the function a = input(value = ) again.
between I have tired something like this, but it doesn't work (the error is still coming out and it unable to prompt the second defined input a = input('enter again')), can anybody explain to me where's the mistake I have done.
if ~isnan(x) || ~isnumeric
a = input('enter again');
else
continue
end
I will really appreciate all the help.
Try the following to keep on pressing user to enter the values that abide by your conditions. As per my comment, the post gives a great idea of how you can achieve this. It is not using OR but AND to have a firm condional validation.
while ~(~isempty(a) ...
&& isnumeric(a) ...
&& isreal(a) ...
&& isfinite(a) ...
&& (a == fix(a)) ...
&& (a > 0))
a = input('Enter the number of dice to roll: ');
end
try this
a = NaN;
while isnan(a) || ~isreal(a)
a = input('value=','s');
a = str2double(a);
end

I need a Script that brings up a Gui on touch in Roblox?

How do I make a script bring up a shop GUI when a brick is touched?
And how should I make the "buy" stuff in the shop GUI?
You will be needing to make that Shop Interface yourself,
but i will give you the "GUI Giver" script.
Note: You must put the Script Inside the Brick/Part.
local GUI = game:GetService("ServerStorage"):WaitForChild("GUI") -- Recommended to place your GUI inside of ServerStorage
script.Parent.Touched:Connect(function(hit)
local Player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if Player then
if not Player:WaitForChild("PlayerGui"):FindFirstChild(GUI.Name) then
GUI:Clone().Parent = Player.PlayerGui
end
end
end)
Make a script that connects a brick's 'Touched' event to a function which uses the "getPlayerFromCharacter" method of game.Players to find the player then inserts the GUI into the player's "PlayerGui". For example:
function newGUI()
--enter something that makes a shop GUI then at the end returns the 'ScreenGui' it's in.
end
script.Parent.Touched:connect(function(hit)
local player = game.Players:getPlayerFromCharacter(hit.Parent);
if player ~= nil then
newGUI().Parent = player.PlayerGui;
end
end)
The following code can be used to give the player the shop gui:
local ShopGui = game.Lighting.ShopGui -- This should be the location of your gui
local ShopPart = workspace.ShopPart -- This should be the shop part
ShopPart.Touched:connect(function(hit)
if hit.Parent == nil then return end
if hit.Name ~= "Torso" then return end
local Player = game.Players:playerFromCharacter(hit.Parent)
if Player == nil then return end
if _G[Player] == nil then _G[Player] = {} end
if _G[Player].ShopGui == nil then
_G[Player].ShopGui = ShopGui:Clone()
_G[Player].ShopGui.Parent = Player.PlayerGui
end
end)
ShopPart.TouchEnded:connect(function(hit)
if hit.Parent == nil then return end
local Player = game.Players:playerFromCharacter(hit.Parent)
if Player == nil then return end
if _G[Player] == nil then return end
if _G[Player].ShopGui ~= nil then
_G[Player].ShopGui:Destroy()
_G[Player].ShopGui = nil
end
end)
Note that "ShopPart" should be a big part that cover the whole shop area (preferable invisible)
Then you also have to build a shop gui.
In the shop gui you should make TextButtons (or image buttons) that each contains the following script:
local Cost = 100
local ThingToBuy = game.Lighting.Weapon -- Make sure this is right
script.Parent.MouseButton1Down:connect(function()
local Player = script.Parent.Parent.Parent.Parent -- Make sure this is correct
if Player.leaderstats["money"].Value >= Cost then -- Change "money" to anything you want (it must be in the leaderstats tho)
Player.leaderstats["money"].Value = Player.leaderstats["money"].Value - Cost
ThingToBuy:Clone().Parent = Player.Backpack
-- GuiToBuy:Clone().Parent = Player.PlayerGui
end
end)
The code ain't tested, so it might contain errors. And you might need to change more stuff than mentioned. But it should give you an idea on how to make the shop gui =)