Not really, i wanted the players to all be able to wallrun with no problems, but i also want them to be able to wallrun at the same time (since sometimes people’s wallrun takes ages)
Edit: does object value save instances? If so, that could be a solution.
local isWallRunning = {}
-- player starts wall running
isWallRunning[player] = true
-- check if player is wall running
if isWallRunning[player] then
end
Not if you were to give each player his/her own BoolValue instance (parented to the player object itself) which represents whether or not that particular player’s character is currently wallrunning. Then when a wallrun is performed by any given player, this created BoolValue instance can be checked for the specific player and the script can act accordingly (don’t perform the wallrun or perform the wallrun as intended).
You can also opt to use an array (which stores player objects in an array which are currently wallrunning) as this post suggests however you’ll need to manage the array by inserting player objects into it when a player begins wallrunning and removing player objects from it when a player stops wallrunning (or leaves the game), with this solution only the script itself will be able to determine if a player is wallrunning or not whereas with instance values parented to the player any script will be able to ascertain whether or not a player is currently wallrunning.
Pretty much i make an array myself everytime a player wants to wallrun and store everything there? Although, if i made an array already but its inside when the player pressed ‘E’ (so the remote event fires and i already have an array in it so for example:
remote.OnServerEvent:Connect(function(plr)
local arrayTest = {true, false, "E"}
wallrun(arrayTest)
end)
Would ‘arrayTest’ be local to each player/would that work (and also will it still be local when i give the array to the function, im pretty sure it is but just making sure)
Yes, since each time the server is fired it is being done so by a single client and a new variable named “arrayTest” is declared and assigned a table value containing information regarding whether or not that particular client is currently wallrunning.
I was referring to arrays/dictionaries all in the same (they are both just different table structures), as such each would still need to be indexed which wouldn’t necessarily make one more advantageous than the other.
To add to this storing a BoolValue instance inside the player object would likely be the best solution as it would allow for other scripts to easily check whether or not a player is currently wallrunning without necessitating the use of RemoteInstances/BindableInstances to facilitate the exchange of data/information between scripts of varying class types.
Yeah I don’t think you know what you’re talking about.
An array
-- array == list of keys
local array = {a,b,c}
If you want to find an element in an array, you would do table.find() which performs a binary search. A binary search goes through each element one by one until it finds the right one. The bigger the array the longer it’ll take to find.
A dictionary (which I used in my post)
-- dictionary == list of of key/values
local dictionary = {a = true, b = true, c = true)
If you want to find something in a dictionary you do dictionary[key] which runs a hash function. I won’t explain exactly how a hash function works (you can find good videos on it). The point is, no matter the size of the dictionary it will be indexed in a (n almost) set number of steps, contrary to an array which takes longer the bigger it gets.
You shouldn’t assume they are the same when talking because they are not an they behave differently. Especially when you replied to me saying “you can also use arrays”. If you want to talk about either arrays or dictionaries you say “table”.
If you want you can make the argument “well using an array will have a negligible difference because the array will be very small (however many players there are)”.
While yes it’s probably negligible to worry about indexing on a table that will have max 20 elements, the point is still true and I personally always use dictionaries when I want to index values to be consistent.
In this scenario the difference between an array/dictionary would be negligible hence I was referring to them both collectively as the same (as tables).
Here’s a little benchmark test which shows how little the difference is even on data structures which contain many thousands of entries (in the scenario in this thread the datastructure would likely contain less than 100 items).
Also in future please don’t reply to my post 6 hours after the fact expecting me to remember everything you had previously replied with in the thread.
If you want to talk about an array you say “array” If you want to talk about a dictionary you say “dictionary” If you want to talk about an array or a dictionary you say “table”
This is accepted knowledge since arrays and dictionaries behave differently. It’s like saying “train” when you are talking about cars.
I said the difference is negligible, that does not change the fact that you said “array” when talking about “tables” which is why I thought you were talking about “arrays”
wallrun(TestTable)
local created = TestTable["created"]
created = true
end
its either it did not save the variables i changed because on another function (removing wallrunning) it has to check created and i set the created to true but it is false in the ‘removeWall’ function.
Any mistakes im doing?
local players = game:GetService("Players")
players.PlayerAdded:Connect(function(player)
local wallrunval = Instance.new("BoolValue")
wallrunval.Parent = player
wallrunval.Value = false
--toggle this value when the player is wallrunning/not wallrunning
end)
Hmm, i applied all of that to my script and didnt work, here is my script since i think its another problem…
local function remove(HRP,tablexd)
local char = HRP.Parent
print(tablexd.created)
if tablexd.created == true and tablexd.bodyVelocity1 ~= nil then
tablexd.bodyVelocity1:Destroy()
tablexd.created = false
tablexd.bodyVelocity1 = nil
tablexd.anim1:Stop()
if tablexd.left2 == true then
bounce(false, HRP,tablexd)
end
end
end
end
end
Thanks
Edit: seems that in the first wallrun it works perfectly but in the second one (if you wallrun to another wall) it will not even create? It makes me jump though, maybe its deleting it?
Edit2: had to just remove the part where it consistently removes it (i dont even remember why i added it)