I’m trying to set the Humanoid State to physics so that it won’t interfere with my own animations once I add them, but the problem is that the Humanoid State doesn’t change to physics. It prints the humanoid state it is currently doing. I’ve read some posts and I can’t find anything that helps this.
Also, in the Local Script, I have already tried to use humanoid:ChangeState but it has not changed anything at all.
I don’t see at all why you would want to manually create a seat weld from one object to another when you could just do this:
make a seat, unanchor it and weld it to the animal model
Whatever animation you want to have played, set it’s action type (i forgot what it was called) to idle and then play it on the client.
Also, don’t invoke clients from the server, use a remote event for that because it is possible that the server could yield infinitely if the client’s invoke function decides to not work or infinitely yield
I’m trying to make a horse like in Horse Valley 2 or (an older game) Meadows Ranch. The player can run straight through the horse. As far as I know, you can’t put a seat on the horse to get the player to sit if the player can run straight through the horse.
I changed the invoke client to a remote function that is invoked from the client when the player presses E, instead of when the horse is hit. I found that simply playing my own animation when the player is welded helped with my problem above. The script was originally working with the client invoke from the server, but I read your reply and changed it. Now I am having a new problem.
Here’s my code.
I am getting an error that says “attempt to index nil with ‘Position’”. This is the server side of the remote function. I have looked for solutions and I was unable to find any that fit my problem. Thank you for taking time to reply to my issue above, by the way.
u can just set the seat to cancollide false and weld it to something so it won’t fall into the nothing, players can still sit in seats if they aren’t cancollide true
Thanks for the reply. However, this still does not solve the error I was getting earlier, and I’m still looking for why that isn’t working. I’d still like to find the error as this will still apply if I later need to teleport a player somewhere or something similar. The weird part is that I have the same line of code with the variables defined the same in other scripts, but those are working fine.
local Char = hit:FindFirstAncestorOfClass('Model')
local HumanoidRootPart = Char:WaitForChild('HumanoidRootPart')
if HumanoidRootPart then
end
The only other reason i can think of this happening is, either you’re not indexing the model which the humanoid resides in or you’re just indexing the humanoidrootpart before it can load in. The code above should help
local EFunction = ReplicatedStorage:WaitForChild("EFunction")
local SitPart = workspace.Horse.HorseTestModel.HorseTest
EFunction.OnServerInvoke = function(player)
print("Test1")
local char = player
local Humanoid = char:FindFirstChild("Humanoid")
local HumanoidRootPart = char:WaitForChild("HumanoidRootPart")
print("Test2")
if HumanoidRootPart then
HumanoidRootPart.Position = SitPart.Position + Vector3.new(0,2,0)
local weld = Instance.new("Weld")
weld.Part0 = HumanoidRootPart
weld.Part1 = SitPart
weld.C0 = HumanoidRootPart.CFrame:Inverse()
weld.C1 = SitPart.CFrame:Inverse()
weld.Parent = script.Parent
local character = char:FindFirstChild("Character")
print("Test3")
end
end
This is my new code. I moved the script (this is the server script) into ServerScriptService after realizing I left it in the model. This did not seem to help much. I tried putting your code, as you can see above, but now all it says is "Infinite yield possible on ‘Players.Crystal0314:WaitForChild(“HumanoidRootPart”)’
The code only gets to “Test1”.
I have no clue what to do, because as far as I have researched, this should work perfectly fine. Thanks for all the help. Also I figured out how to add code in replies. (Yay!)