Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

ROBLOX: Script error "LocalPlayers is not a valid member of DataModel help!?

Script error says "LocalPlayers is not a valid member of DataModel"

Here is the script>

wait(3) Player = game.LocalPlayers.Character animation1 = Player.Humanoid.LoadAnimation(script.Animation1) animation2 = Player.Humanoid.LoadAnimation(script.Animation2) animation3 = Player.Humanoid.LoadAnimation(script.Animation3) CanEmote = true

script.Parent.MouseButton1Click:connect(function() local emote = math.random(1,3) if emote == 1 and CanEmote == true then animation1:Play() CanEmote=false wait(2) CanEmote=true

 else if emote == 2 and CanEmote == true then
 animation2:Play()
 CanEmote=false
 wait(2)
 CanEmote=true

 else if emote == 3 and CanEmote == true then
 animation3:Play()
 CanEmote=false
 wait(2)
 CanEmote=true
 end 

end end end)

1 comment

0

You should edit your question to use Lua code formatting (select your code and press the the purple lua button)

3 answers

✓ Accepted answer

As the error says, .LocalPlayer is not a member of "DataModel". The game is a DataModel.

It even tells you the line that it's wrong on -- the second one.

it should be game.Players.LocalPlayer, not game.LocalPlayer.


Instead of wait(3), you can use the CharacterAdded event. This will make your script start slightly faster, and never have a risk of breaking randomly.

I suggest using accurate names. Player is not a player but a character.

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()

Lots and lots of errors. It is elseif, like a suffix. And instead of using wait, use PlayerAdeed. So all the error fixes I done for you will be shown as a example here.

local thing = true

game.Players.PlayerAdded:connect(function(plr)

if thing == true then

warn("ERROR ERROR ERROR ?????? ERROR ERROR ERROR WITH"..plr.Name)
elseif thing == false then

error("EVEN MORE ERROR EVEN MORE ERROR EVEN MORE ERROR ?????? EVEN MORE ERROR EVEN MORE ERROR EVEN MORE ERROR WITH "..plr.Name)
end
end)

Another common mistake is LocalPlayer. Well, hey. The script aint reading your mind to see what you mean by that! You use LocalPlayer on LocalScripts. For more info, check out the Common Mistakes area in this website. Hope this helps and if this fixes your problem dont forget to accept awnswer!

This discussion is preserved as it was. New answers, comments, and votes are closed.