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

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

Related

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

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

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!

Break / Stop while loop from user input at the Matlab command line

I am attempting to create a while loop that will loop continuously until input from the user at the command line.
I have tried two implementations of this the first, the first derived from this bit of python. The problem being that you must enter something other than exit every time you want to iterate through loop.
global active
active = true;
while active == true
userInput = input('enter: ','s');
inputHandler(userInput)
disp(rand)
pause(1);
end
function inputHandler(value)
global active
if value == 'exit'
active = false;
end
end
The second was
global loopFlag
loopFlag = true
while loopFlag == true
%some awesome code happens here
end
with the idea being that you could enter at the command line loopFlag = false while the code was executing and it would stop.
I know this can be done through the use of a toggle button but I would prefer not to have to go that route unless absolutely necessary.
active = true;
while active == true
active = input('Enter true or false ' );
disp(rand)
pause(1)
end

Closing MATLAB GUI application programmatically without using error()

I am trying to make it so the application/gui closes completely if the user clicks cancel or exit of an input dialog. The tag of my gui is called window however using close(handles.window); leads to the program looping through once and then (after the user clicks cancel or exit again) reaching the close(handles.window); line which, of course, leads to an Invalid figure handle error.
Is there any method to close the application without the need for producing an error and not closing the entire MATLAB environment (like quit and exit). The error() is my temporary fix which works but I don't want the application to seem like it has crashed.
I have tried close all but that has no effect. It's worth noting that the application does reach inside the if statement if the user clicks cancel or exit.
I have also tried setting a variable and having the close commands outside the while loop.
apa = getAvailableComPort();
apList = '';
i = 0;
for idx = 1:numel(apa)
if i == 0
apList = apa(idx);
else
apList = strcat(apList, ', ', apa(idx));
end
i = i + 1;
end
prompt = {'Enter COM PORT:'};
title = 'COM PORT';
num_lines = 1;
def = apList;
COM_PORT = inputdlg(prompt,title,num_lines,def);
% Keep asking for a COM PORT number until user gives a valid one
while sum(ismember(apa, COM_PORT)) == 0 % If the COM port comes up in the available COM ports at least once
% If user clicks cancel, close the guide
if isempty(COM_PORT) == 1
error('Closing...'); % HERE IS THE PROBLEM
end
prompt = {'Invalid COM PORT'};
title = 'Invalid COM PORT';
COM_PORT = inputdlg(prompt,title,num_lines,def);
end
The function getAvailableComPort is found at http://www.mathworks.com/matlabcentral/fileexchange/9251-get-available-com-port
This entire piece of code is at the top of the gui_OpeningFcn() function.
Have you tried putting a break after the close(handles.window). The break will exit the while loop so it won't hit that line again.
if isempty(COM_PORT) == 1
close(handles.window)
break
end
This way the while loop stops after closing the window. IF you need to do more cleanup besides just closing the window then set an error flag .
%Above while loop
errorFlag = False;
if isempty(COM_PORT) == 1
close(handles.window)
errorFlag = True;
break
end
%OutSide of While loop
if errorFlag
%Do some more clean-up / return / display an error or warning
end
Also FYI, you don't need to do isempty(COM_PORT) == 1 ... isempty(COM_PORT) will return true/false without the == 1
Your requirements aren't really clear, but can't you just protect the close operation by doing
if ishandle(handle.window)
close(handle.window)
end
This will prevent the close from being attempted if the window has already been destroyed.
Why don't you use a simple return and a msgbox to inform that user has clicked on Cancel?
if isempty(COM_PORT)
uiwait(msgbox('Process has been canceled by user.', 'Closing...', 'modal'));
delete(your_figure_handle_here);
return;
end
I tried using the return statement in conjunction with close(handles.window) but received the error:
Attempt to reference field of non-structure array.
Error in ==> gui>gui_OutputFcn at 292 varargout{1} = handles.output;
So it seems just removing that line on 292 solved the issue.

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