Sit Script Is Broken!

Hello! Im trying to make a sit script for my slide!

The Issue is it doesn’t work at all, This came in the output

  12:38:10.024  Player is not a valid member of DataModel "Tinpot.wav's Difficulty Chart"  -  Server  -  Script:2
  12:38:10.024  Stack Begin  -  Studio
  12:38:10.024  Script 'Workspace.Part.Script', Line 2  -  Studio  -  Script:2
  12:38:10.024  Stack End  -  Studio
  12:38:10.024  Player is not a valid member of DataModel "Tinpot.wav's Difficulty Chart"  -  Server  -  Script:2
  12:38:10.024  Stack Begin  -  Studio
  12:38:10.024  Script 'Workspace.Part.Script', Line 2  -  Studio  -  Script:2
  12:38:10.024  Stack End  -  Studio

Here’s the script

script.Parent.Touched:Connect(function(hit)
	if game.Player:GetPlayerFromCharacter(hit.Parent) then
		hit.Parent.Humanoid.Sit = true
	end
end)
1 Like

Players, not Player. That is all to it.

2 Likes

Like this?

script.Parent.Touched:Connect(function(hit)
	if game.Players:GetPlayersFromCharacter(hit.Parent) then
		hit.Parent.Humanoid.Sit = true
	end
end)

Also which Player from the script?

or

It’s the “game.Player” one

30303030

1 Like

game.Players, not game.Player. GetPlayerFromCharacter was fine.

I’d recommend something like this though.

local Players = game:GetService("Players") -- it's good practice to obtain services via :GetService

local part = script.Parent

part.Touched:Connect(function(other: BasePart)
    local player = Players:GetPlayerFromCharacter(other.Parent)

    if player then
        player.Character.Humanoid.Sit = true
    end
end)
2 Likes