Why is this code not working?

Did I do something wrong here I’m getting an error.

player.Character.Torso.Anchored = true
3 Likes

Is that your entire script? Roblox studio doesn’t magically know what player is referring to, it’s just a variable name.

2 Likes

No, the script is much longer however this is the line I need fixed, Should I do

player = game.Players.LocalPlayer

before it to refrence player?

Edit when I did that the error still said

20:03:11.823 - Torso is not a valid member of Model “Workspace.Aid_nPlaysYT”

1 Like

If you’ve never even created a variable named player then the word player has no value, you first need to assign a value to it like that.

Variables

You should use WaitForChild in that case

player.Character:WaitForChild("Torso").Anchored = true
2 Likes

Here is the part of the script that the code is on

function _m.WarnCustomer(warning,reason,player)
	game:GetService('StarterGui'):SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
	player.Character.Torso.Anchored = true
	if warning == 1 then

edit: there is more but its long so I won’t put the whole script.

1 Like

Are you using r6 or r15? R15 had an upper and lower torso.
You could add local char = player.Character or player.CharacterAdded:wait() to ensure that player character has been properly loaded.

2 Likes
game:GetService("Players").LocalPlayer.Character.Humanoid.Torso.Anchored = true

Torso not is member of model Character (Workspace.Player)

1 Like

I think I’ll use a different warning system this one has to many errors. After that there are like 50 more and I think the code breaks tos.

1 Like

Pass me the script and I’ll fix it for you

2 Likes

@AidanPlaysYT_Real Check your game settings under where it shows avatar/appearance. If it’s R15 then Torso isn’t a thing. It’s either UpperTorso or LowerTorso. Torso is only for R6.

2 Likes

There’s a possibility that you’re using R15. In R15 rigs, there’s an “UpperTorso” and “LowerTorso.”

2 Likes

I meant It’s instead, UpperTorso and LowerTorso

1 Like

Okay Here Is The Script (I’m sending in file format because its long also I warned you guys it was bad so don’t blame me. It does epic stuff though.)
AutoWarn.rbxm (3.8 KB)
Download that then go in a studio and drag it from files to studio and it will show the script(s)

What is your thing set to? R15 or R6?

2 Likes

R15 I am pretty sure. (Idk but I think)

Change it to R6 and then it should work. Also, please warn members if you are going to ask them to download something that contains inappropriate language/profanity.

Yeah, I downloaded the script and changed Torso with UpperTorso and the script ran fine. Use UpperTorso is you use R15 and Torso for R6.

Only other issue is you won’t be able to call SetCore on the server. You would need to add a RemoteEvent to communicate with a LocalScript for that to work. This will only present a warning in the output.

1 Like

or change the script to .UpperTorso.Anchored = True and .LowerTorso.Anchored = True

1 Like

try using HumanoidRootPart as it applies to all rigtypes so you should not worry about using Torso parts anymore

-- server(normal) script in startercharacterscripts
local char = script.Parent
local humrp = char:WaitForChild("HumanoidRootPart")
humrp.Anchored = true

local wFun = script.Warnings
what is this?

1 Like