Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

walkspeed script for certain players not working?

Asked by
KenzaXI 166
8 years ago
local plrs = {"DarkFlameCrimsonXana", "PrimeCrimson", "RebornProductions", "Delshark44"}
local bs = script.Parent
function onTouch(Brick)
    local Player = 
    Brick.Parent:findFirstChild("humanoid")
    if (Player.Name == (plrs))then
        Player.Walkspeed = 100
    end
end
bs.Touched:connect(onTouch)

I don't get why it's not working, the output shows no errors and yet it's not working...

0
What you'll also need to do is add "Player" to plrs, if you want to try your script in studio. funyun 958 — 8y

2 answers

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
8 years ago

Your if statement on line 6 is checking if their name is a Lua Table, which it obviously isn't.

To fix this, let's make this a Dictionary and change line 6:

local plrs = {DarkFlameCrimsonXana = true, PrimeCrimson = true, RebornProductions = true, Delshark44 = true}
local bs = script.Parent
function onTouch(Brick)
    local Player = game.Players:GetPlayerFromCharacteR(Brick.Parent) --This is a better method of getting the Player's name if it exists.
    if (plrs[Player.Name])then
        Player.WalkSpeed = 100
    end
end
bs.Touched:connect(onTouch)
0
Also, make sure that 's' in Walkspeed is Capitalized. The property is 'WalkSpeed', not 'Walkspeed'. dyler3 1510 — 8y
0
cheers, i broke my arm so i could only just check it out KenzaXI 166 — 8y
Ad
Log in to vote
-1
Answered by
KoreanBBQ 301 Moderation Voter
8 years ago
local plrs = {"DarkFlameCrimsonXana", "PrimeCrimson", "RebornProductions", "Delshark44"}
local bs = script.Parent
function onTouch(Brick)
    local Player = 
    Brick.Parent:findFirstChild("Humanoid") --Capitalized H
    for i,v in pairs(plrs) do
    if Player.Parent.Name==v then
        Player.Walkspeed = 100 -- You might have to write WalkSpeed idk i forgot but try it like this
    end
    end
bs.Touched:connect(onTouch)

Answer this question