✓ Accepted answer
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", "")
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
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
failures += 1
end
end
if failures == #allowedPlayers then
end
1 comment
ok i know how to do this hold on let me write this out