I'm trying to make it where multiple peoples name can be stored inside the parameter in the variable allowedPlayers
local object = script.Parent local fireObject = game.ReplicatedStorage.speedFire local player = workspace local allowedPlayers = ("M9F", "") ---- this is what I need help with local debounce = false local function giveSpeed(hit) if debounce == false then debounce = true if hit.Parent:FindFirstChild("Humanoid")then if hit.Parent.Name == allowedPlayers then hit.Parent.Humanoid.WalkSpeed = 50 hit.Parent.Humanoid.JumpPower = 75 if not hit.Parent.Head:FindFirstChild("speedFire")then local clonedFire = fireObject:Clone() clonedFire.Parent = hit.Parent.Head end end end debounce = false end end object.Touched:Connect(giveSpeed)
Alright, if you dont know, any string array can have as many strings in it as you want, as long as you specify which number it is. for example, you cannot put in a string = the string array because it doesnt work that way, you have to specify which string in the string array you want to ad or change, like stringarray[2] or the next one after that is stringarray[3], the lowest is 0, so you may be wondering "how do i insert player names into different string arrays" well fun quick story, when i was new to scripting, i used math.random but that was stupid and the sloppiest idea ever, anyway, to do this, change the number everytime and be PREDICTABLE WHILE YOU DO IT, math .random isnt predictable and two numbers could be the same,
the quick answer? Just increment a value everytime a player is added so the numebr is always different and is 1 higher than the last. so your code should be like this (i added a value called num):
local object = script.Parent local fireObject = game.ReplicatedStorage.speedFire local player = workspace local allowedPlayers = ("M9F", "") ---- this is what I need help with local debounce = false local num = 0 local function giveSpeed(hit) if debounce == false then debounce = true if hit.Parent:FindFirstChild("Humanoid")then if hit.Parent.Name == allowedPlayers[num] then num += 1 --adds 1 , same as num = num + 1 hit.Parent.Humanoid.WalkSpeed = 50 hit.Parent.Humanoid.JumpPower = 75 if not hit.Parent.Head:FindFirstChild("speedFire")then local clonedFire = fireObject:Clone() clonedFire.Parent = hit.Parent.Head end end end debounce = false end end object.Touched:Connect(giveSpeed)
hope this helps :3
oh hold on i jsut realised i misunderstood the qustion, ok i understand now, lemme answer it correctly this time heheh sorry.
So your trying to test all of the player names in the string array to see if they math the player being tested. simple, make a pairs loop like this.
failures = 0 for _,i in pairs(allowedPlayers) do if not i == hit.Parent.Name then--so this means if the player name does NOT match whats in the string being testing in the string array failures += 1 --adds one end end --any code after the loop will run when the loop finished, which means this code below will run once all strings in the array are tested if failures == #allowedPlayers then--# means number or amount, so #allowedPlayers means the amount of strings in that array, so if all the strigns failed, then below code with execute --code you want end