Humanoid.Sit not working

Could you send all of the code inside of the mousePos script. Either here or in my DMs. Whatever works for you.

local uis = game:GetService("UserInputService")
local remoteevent = game.ReplicatedStorage.MousePosEvent
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local mouse = plr:GetMouse()
local held = false

uis.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		held = true
		print("Left mouse button IS BEING held!")
		end
end)
uis.InputEnded:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		held = false
		print("Left mouse button is NO LONGER being held!")
	end
end)

while task.wait(0.01) do
	if held == true and char:WaitForChild("Humanoid").Sit == true then
		print("sent")
		remoteevent:FireServer(mouse.hit.p)
		if char:WaitForChild("Humanoid").Sit == true then
			remoteevent:FireServer(mouse.hit.p)
		end
	end
end

This code should work for you.

local uis = game:GetService("UserInputService")
local runService = game:GetService("RunService")

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local mouse = plr:GetMouse()
local sitting = false
local held = false

local remoteEvent = game.ReplicatedStorage.MousePosEvent

uis.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		held = true
	end
end)
uis.InputEnded:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		held = false
	end
end)

char:WaitForChild("Humanoid"):GetPropertyChangedSignal("Sit"):Connect(function()
	if char.Humanoid.Sit then
		sitting = true
	else
		sitting = false
	end
end)



runService.Heartbeat:Connect(function()
	if sitting and held then
		remoteEvent:FireServer(mouse.hit.p)
	end
end)
2 Likes

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