How can I change a walkspeed to like a variable - roblox

local playerName = OykkoIsBack
Players.(playerName).Character.Humanoid.JumpPower = 100
so I want to set my jump power to the variable that has the players name? im new to roblox
scripting and this happened in my output
Expected identifier, got '('
something similar to this happened
i wrote this if game.Workspace.IntValue.Value = 0 then
print("Value is 0")
but i figured this out by adding a another = but this time i can't figure it out so i need someone to help me!
really appreciate it if you could help me!

OykkoIsBack should have double quotes around it, so the first line should be local playerName = "OykkoIsBack". Without the quotes, it is not a string and cannot be assigned to playerName.
The other issue is with Players.(playerName). The syntax for indexing a table in Lua is table[key]. In your case it should be Players[playerName]
Here is the code
local playerName = "OykkoIsBack"
Players[playerName].Character.Humanoid.JumpPower = 100
What this does is sets playerName to OykkoIsBack, then it gets the humanoid of the player with playerName and sets their jump power to 100.

I’m quite new at scripting too, so I might be wrong but here’s what I think the mistake is:
First of all you put
Players.(playername).Character.Humanoid etc.
I think ‘playername’ shouldn’t have brackets?
Secondly, you just set the jumpPower to 100?? Try replacing the 100 with a variable, so after the = try writing the variable name.
I think this because the error is saying there was a bracket where it expected something else (from what I know) so I think it’s just the playername brackets.

Related

Cimplicity Screen - one object/button that is dependent on hundreds of points

So I have created a huge screen that essentially just shows the robot status for every robot in this factory (individually)… At the very end of the project, they decided they want one object on the screen that blinks if any of the 300 robots fault. I am trying to think of a way to make this work. Maybe a global script of some kind? Problem is, I do not do much scripting in Cimplicity, so any help is appreciated.
All the points that are currently used on this screen (to indicate a fault) have very similar names… as in, the beginning is the same… so I was thinking of a script that could maybe recognize if a bit is high based on PART of it's string name characteristic. The end will change a little each time, but I am sure there is a way to only look for part of a string and negate the rest. If the end has to be hard coded, that's fine.
You can use a Python script in Cimplicity.
I will not go into detail on the use of python in Cimplicity, which is well described in the documentation indicated above.
Here's an example of what can be done... note that I don't have a way to test it and, of course, this will work if the name of your robots in the declaration follows the format Robot_1, Robot_2, Robot_3 ... Robot_10 ... Robot_300 and it also depends on the Name and the Type of the fault variable... as you didn't define it, I imagine it can be an integer, with ZERO indicating no error. But if you use something other than that, you can easily change it.
import cimplicity
(...)
OneRobotWithFault = False
# Here you get the values and check for fault
for i in range(0, 300):
pointName = f'MyFactory.Robot_{i}.FaultCode'
robotFaultCode = cimplicity.point_get(pointName)
if robotFaultCode > 0:
OneRobotWithFault = True
break
# Set the status to the variable "WeHaveRobotWithFault"
cimplicity.point_set("WeHaveRobotWithFault", OneRobotWithFault)

If WinExist using variable and RegEx

Disclaimer: Yes I have read another StackOverflow posts similar to mine, but none were using RegEx on the title, and I couldnt find a solution.
I need to open a certain window that is like this:
PlayerName - Game Version 1.2.15
where PlayerName can be everything (like aywradwe, john or flyingcar82)
I can get the player name from a certain function getName() that is irrelevant for my question and its working properly.
playerName = getName()
And then I tried to open the correct window by using that playerName variable and RegEx to match any possible version of the game.
SetTitleMatchMode RegEx
playerName = getName()
IfWinExist, playerName - Game Version.*
{
WinActivate
Sleep, 500
WinMaximize
}
But it tries to match the title using "playerName" and not its value. I also tried with %playerName% and it doesnt work either...
What am I missing?
Two problems here, and they come from using the legacy syntax wrong.
Problem 1:
playerName = getName()
You're using the deprecated legacy way of assigning literal text to a variable (=).
Now the variable playerName holds the literal text "getName()".
:= should be used to assign the result of an expression to a variable:
playerName := getName()
Problem 2:
Usage of the deprecated legacy IfWinActive command.
Not exactly a problem on it's own, but combined with wrong usage of the legacy syntax it is. In a legacy statement there you'd indeed refer to the variable by doing %playerName%, and that would work if you fixed Problem 1.
But lets do it the proper way and use the newer WinExist() function:
if (WinExist(playerName " - Game Version.*")) ;concatenate the contents of a variable and string
{
WinActivate
Sleep, 500
WinMaximize
}
Overall, I'd recommend trying to get rid of the legacy syntax.
Here's a good page on the documentation to get you started between the differences:
https://www.autohotkey.com/docs/Language.htm

Im getting this error: “ braced block of statements is an unused closure, expected expression and expression resolves to an unused function"

This is my first time doing a kinda simple project and these errors shows up.
I've been trying for the past 2-3 hours to get this work.
Any help would be greatly appreciated guys.
Picture: https://i.stack.imgur.com/9YHbT.png
You have typed it a bit wrong, try this instead:
if let uid = KeychainWrapper.standard.string(forKey: "uid") {
}
You either need to assign the if let to a variable name or use _.

Swift - Getting Error while using replacingOccurrence

So I'm taking Udacity's Swift for Developers course. I attempted to look at the forums for this question but oddly, they were quiet. This is the programming prompt:
var forwardString = "stressed"
var backwardsString = forwardString.characters.reversed()
print(backwardsString)
var lottaLikes = "If likeyou wanna learn Swift likeyou should build lots of small apps cuz it's likea good way to practice."
var noLikes = lottaLikes.replacingOccurrences(of:"like", with:"")
print(noLikes)
For whatever reason, I keep getting this error message:
Be sure that you have replaced all occurences of the word "like" and removed any extra spaces.
What am I missing here? If you need clarification on this I would be happy to provide it.
Thank you
It may be that your code gets the job done, but only because your variable lottaLikes is written in a weird way. You usually would have two spaces surrounding the word "like" so just removing the word would leave 2 spaces in a row. I would suggest writing the following line:
var noLikes = lottaLikes.replacingOccurrences(of:"like ", with:"")
It may be that Udacity is not checking the actual output, but the code itself. If so, It may be looking for something like I wrote above.
If this still does not work, you may want to write another line like so:
var noExtraSpaces = noLikes.replacingOccurences(of: " ", with: " ")

double datatype is not assigning large value

I am trying to assign a large value to a double datatype for example
double someValue = 36028797018963967D;
but the problem is, when I debug the value of variable someValue, it becomes 36028797018963968D and I cant figure out why.
Any help will be appreciated,
Thanks!
Both of these numbers are the same in 64 bit floating point. What gets printed is an artifact of the method used to print them. Try this:
assert(36028797018963967D == 36028797018963968D)
It works!