It doesn’t use a humanoid, maybe I should add it to the beyblade, but I’ve hardly worked with that before. Would I need to create separate joints or something?
It instantly sets velocity, in .Stepped. You can see all of that in the code above.
It doesn’t use a humanoid, maybe I should add it to the beyblade, but I’ve hardly worked with that before. Would I need to create separate joints or something?
It instantly sets velocity, in .Stepped. You can see all of that in the code above.
The MoveDirection
of the character is a normalized vector, meaning the length of the vector is 1. You’ll want to multiply it by the speed you want the beyblade to move. For example:
local moveDirection = player.Character.Humanoid.MoveDirection
local moveSpeed = 15
workspace[beyblade].PrimaryPart.AssemblyLinearVelocity = moveDirection * moveSpeed
This will cause the beyblade to move at the speed you specified in the direction the character is facing.
As for jumping, you’ll want to use the Humanoid.Jump
function:
if UserInputService:IsKeyDown(Enum.KeyCode.Space) then
player.Character.Humanoid:Jump()
end
This will cause the character to jump if the space bar is pressed.
using a humanoid would make it easier in some parts but harder in others, you would not have to create/rename any joints the only thing is you would need a HumanoidRootPart and maybe a torso and head for it to be controlable. The velocity instantly being set might be the issue since it doesn’t allow the physics to work but there might be another way to solve it.
Here is some old code for tilting, might work if you replace some things manually and adjust it
function Lerp(a, b, t)
return a + (b - a) * t
end
local root = character.RootPart --Rootpart of model
local tiltX = 0
local tiltZ = 0
local WalkSpeed = 16 --whatever the max movementspeed is for your object
game:GetService("RunService").Stepped:Connect(function()
local movementVector = root.CFrame:vectorToObjectSpace(root.Velocity/math.max(WalkSpeed,0.01))
tiltX = math.clamp(Lerp(tiltX, movementVector.Z,1),-.2,.2)
tiltZ = math.clamp(Lerp(tiltZ, math.clamp(movementVector.X,-1,1),1),-.2,.2)
if tiltX > 0 then
tiltX-=(tiltX*2)
elseif tiltX < 0 then
tiltX-=(tiltX*2)
else
tiltX = 0
end
if tiltZ > 0 then
tiltZ-=(tiltZ*2)
elseif tiltZ < 0 then
tiltZ-=(tiltZ*2)
else
tiltZ = 0
end
--not sure if tiltX/Z are in the right spots, mess around with that
root.Orientation = Vector3.new(tiltX,0,tiltZ)
end)
Gonna eat food so won’t respond in a while
Already doing the first part, but I’ll try adding a humanoid then using a Jump function
Alright, that might solve it try to add that.
Doesn’t work it seems,
UserInputService.InputBegan:Connect(function(input,gpe)
if gpe then return end
if input.KeyCode == Enum.KeyCode.Space and alreadyOwn then
local beyblade = workspace[player.Name.." Beyblade"]
beyblade.Humanoid.Jump = true
end
end)
The code I used
You can’t just check if the player is touching the ground, because the client doesn’t know if the player is touching the ground.
You have to use remote events so the server can check it for you.
local re = script.Parent.RemoteEvent
re.OnServerEvent:Connect(function(player, jump)
local character = workspace:FindFirstChild(player.Name)
if not character then return end
if character:FindFirstChild("Humanoid") then
character.Humanoid:Jump()
end
end)
re.OnClientEvent:Connect(function(jump)
local character = workspace:FindFirstChild(player.Name)
if not character then return end
if character:FindFirstChild("Humanoid") then
character.Humanoid.Jump = jump
end
end)
Huh? I’m not understanding here
DId you ever hear of remoteevents
? If no so, please look at this documentation RemoteEvent | Roblox Creator Documentation.
That’s not exactly the issue here, I’m simply not understanding what you’re talking about
Actually it’s easier to check if the player is grounded using the client, I’ve tried this with one of my games and I found client being more accurate
local grounded = true
humanoid.StateChanged:Connect(function(oldState,newState)
if newState == Enum.HumanoidStateType.Landed then
grounded = true
end
if newState == Enum.HumanoidStateType.Freefall then
grounded = false
end
end)
I am talking about that LUA cannot check if the player is touching the ground, for that you will need an remote event to check if the player is touching the ground, the remote event will be fired every millisecond, second or minute depends on how you like to check it. The script cannot check if you are on the ground, so the beyblades won’t move until the character is moving on the ground, like ARSENAL in arsenal the players are walking around a big baseplate that makes their characters move around in the actual game.
The grounded made me kinda laugh but thanks for the advice, this makes the script way simplier.
I don’t really have a need of checking whether the character is on ground atm or not
Well to make the beyblades move, you need to check that so the beyblades can even move as they are controlled by the player movement.
Another issue I guess, not sure how to make it so the other parts rotate with the PrimaryPart? I’m using a Motor6D joint to attach the other parts to the primarypart at the moment
if all the root part is not jointed/welded to another part and all the motor6d’s are descending to the root part they should automatically tilt with it if they’re unanchored
(this is if you use physics or CFrame to rotate it meaning orientation won’t work so pretty stupid of me to use it for the example but I guess you can just change it)
so… just
root.CFrame *= CFrame.Angles(tiltX,0,tiltZ)
Are the values in Radians?
yes and yes
1234567891011121314151617181920