The parameters to Vector3.new are the x, y, z components, not a string. So you want Vector3.new(0,90,0) instead of Vector3.new("0,90,0").
You can use the console output to see these errors and save you a lot of time debugging simple mistakes like these.
local brick = script.Parent
brick.Touched:connect(function(s)
if (s.Parent:FindFirstChild("Humanoid")) then else return end
s.Parent.HumanoidRootPart.Orientation = s.Parent.HumanoidRootPart.Orientation+ Vector3.new(0,90,0)
end)
This seems to make the character go away from the brick, I don’t think I did the orientation thing right, would it be a while true do loop with it constantly changing the orientation by 1 every second?
Not necessarily, if the player was looking straightforward. he would stay at the same orientation due to the camera.
Though you can try it:
local rotation = 90
for i = 1, rotation do
wait(0.1)
s.Parent.HumanoidRootPart.Orientation = s.Parent.HumanoidRootPart.Orientation+ Vector3.new(0,1,0)
end
I would use if statements with a number (For example):
local number = 0
--Your Humanoid comparasion
if number <= yournumber then
number = number + 1
--Then rotate your humanoid
else
YourEvent:Disconnect() --learn in depth what events are to understand this
end
And pls, use the three ` symbols for inser your code
Also you could use while true do and then break it whenever you wan’t
local brick = script.Parent
local plr = game:GetService(“Players”)
brick.OnTouch:connect(function()
while true do
plr.LocalPlayer.Character.HumanoidRootPart.Orientation = Vector3.new(“0,90,0”)
wait(1)
break
end
This would require a value with an if statement to check if the rotation reaches a certain amount. For loops are the quickest and easiest way to achieve this.
Yes, oxazolone’s code worked but it is not really what I am trying to accomplish, which is a smooth rotation of the character for a few seconds, and HabibiBean’s code straight up does nothing (no offense)
@ekuz0diaa I’m assuming this is a server script, in which case you cant use localPlayer to get the player. To the server there is no local player, just a bunch of random player s that are connected to it, so it has no idea which player you’re talking about.
Sorry for not giving instructions, but it does work.
local brick = script.Parent
brick.Touched:connect(function(s)
if (s.Parent:FindFirstChild("Humanoid")) then else return end
local rotation = 10
for i = 1, rotation do
wait(0.1)
s.Parent.HumanoidRootPart.Orientation = s.Parent.HumanoidRootPart.Orientation+ Vector3.new(0,1,0)
end
end)