My module script cant detect the character

i have the following code:

function AnimateUI.typeWrite()
player.LocalPlayer.character.PrimaryPart.Anchored = true
end

in a module script, i want the code to anchor my character but it doesnt work because it says that “character” couldnt found. what can i do?

2 Likes

You typed it wrong, it’s player.LocalPlayer.Character.PrimaryPart.Anchored
Also btw read this

thanks, but i tried that too, idk why, but when i use “character” by black magic it works.
Even if i use “Character”

do you require it by a local script or normal script?

if you are talking about the conection between a server script and a module script, make sense that it doesnt works.
surprisingly, the module script returns me to perfection the local player, however this time isnt it.

Question: why are you doing player.LocalPlayer?

it should be either player.Character or game.Players.LocalPlayer depending on what context the script is required

And also, what exactly is player your script?

i have a variable before that called player that makes reference to the local player

What is player equal to? If player is equal to game.Players.LocalPlayer then do:

player.Character.PrimaryPart.Anchored = true

Else if it’s equal to game.Players do:

player.LocalPlayer.Character.PrimaryPart.Anchored = true

i thought that was pretty obviusly

How about this

function AnimateUI.typeWrite(playerObj)
    playerObj.Character.PrimaryPart.Anchored = true
end

in the requiring script, pass a player object

could be a good idea, i will try it

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.