I’m working on an ability for my game that equips you with a skateboard and allows you to dash in that direction with the effect you’re riding a board.
While it might seem to work, the player and the board do not rotate to the right to give the effect of riding a board. They currently just float straight ahead.
Here is my code,
game.ReplicatedStorage.RemoteEvents.ActivateMeter.OnServerEvent:Connect(function(player)
local char = player.Character
char.PrimaryPart = char.HumanoidRootPart
char.PrimaryPart.Anchored = true
local pos = char.PrimaryPart.Position
local vector = char.PrimaryPart.CFrame.LookVector
char:PivotTo(CFrame.new(char.PrimaryPart.Position + Vector3.new(0, 0.5, 0)) * CFrame.Angles(math.rad(0),math.rad(90), math.rad(0))) --Trying to rotate character here, still no luck
local boardPlr = char:FindFirstChild("Board")
boardPlr:Destroy()
local board = game.ServerStorage.Board:Clone()
local arm = char:WaitForChild("Torso")
local offset = Vector3.new(0, 3, 0)
local fullOffset = arm.CFrame * CFrame.new(offset) * CFrame.Angles(math.rad(0),math.rad(-90), math.rad(0))
board.PrimaryPart.CFrame = fullOffset
board.Parent = workspace
local weld = Instance.new("Weld")
weld.Parent = board.PrimaryPart
weld.Part0 = board.PrimaryPart
weld.Part1 = arm
weld.Name = "Weld"
weld.C0 = board.PrimaryPart.CFrame:inverse() * fullOffset
local connection = board.Hitbox.Touched:Connect(function(hit)
if hit.Parent then
if hit.Parent:FindFirstChild("Humanoid") then
local target = hit.Parent
local targetHum = target.Humanoid
if target and targetHum then
targetHum:TakeDamage(100)
end
end
end
end)--]]
game:GetService("TweenService"):Create(char.PrimaryPart, TweenInfo.new(1, Enum.EasingStyle.Quad), {CFrame = CFrame.new(pos + (vector * 50))}):Play()
wait(1)
connection:Disconnect()
board:Destroy()
EquipSkateboard(char, false)
char.PrimaryPart.Anchor
What I do is store the player’s direction in a variable so I can use it later to tween the character after they have already rotated. I then weld the board to the player and tween the player’s CFrame 50 studs in the forward direction. Although I’d like to rotate the character to the right before the tween to make it look like they’re riding.