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

Im trying to make the bodyposition move when a certain person says a phrase. Why isnt this working?

Asked by 9 years ago

This is my script, and nothing pops up about an error in output either

01door = game.Workspace.LobbyDoor
02local player = game.Players:FindFirstChild("Humanoid")
03End = game.Workspace.EndLob
04 
05 
06function test(name)
07    if player.Name == "koolkid8099, Player" then
08        player:connect(onChatted)
09    end
10end
11 
12function onChatted(msg, recipient, speaker)
13 
14 
15 
View all 33 lines...
1
Fix your code format, please. Goulstem 8144 — 9y
1
ogm git gud nub1111 Perci1 4988 — 8y

1 answer

Log in to vote
1
Answered by 9 years ago

Firstly, you shouldn't be defining your variables like that. Secondly, game.Workspace:FindFIrstChild("Humanoid") is not going to give you a player. If you gave it a second argument set to true, it'd look through everything within everything for a humanoid, but that's your player's character's humanoid - not the player.

You also don't check strings in that way. In addition, you should probably debounce so that you cant keep opening it when it's already opening.

What you want to do is have an event listener waiting for a player to join, and then waiting for that player to speak, then looping through a table of names to see if it returns true:

01admins = {"FlyScript", "koolkid8099", "Player", "etc"}
02door = game.Workspace.LobbyDoor
03status = "closed"
04 
05function nameCheck(name)
06    local valid
07    for _, v in pairs(admins) do
08        if v == name then
09            valid = true
10        end
11    end
12    return valid
13end
14 
15game.Players.PlayerAdded:connect(function(player)
View all 26 lines...

You'd do a similar sort of thing for closing the door.

Ad

Answer this question