Hey there! I have been attempting to make a realistic basketball game, but I have ran into some predicaments. When I change the size of the player, the animation and the ball itself distort. I do not have experience using Motor6ds or anything of this sort, so help is greatly apprectiated.
There has been a video attached displaying my problem, as well as a screenshot of how the ball is set up in the player and the Motor6D stepup.
Video: https://vimeo.com/1059378937?share=copy
Here are the different scripts:
Script Inside of Basketball
-- Detect when a player touches or picks up the ball
local ball = script.Parent -- The basketball part
local possessionTag = "HasBall" -- Name for possession tracking attribute or tag
function AttachBallToPlayer(player, ball)
local character = player.Character
if character then
character:FindFirstChild("Ball").Value = ball
-- Optionally weld the ball to a part of the player for smoother movement
ball.Parent = character
local ballWeld = ball.BasketballWeld
ballWeld.Part0 = character:FindFirstChild("HumanoidRootPart") -- Attach to the root part or hand
end
end
function check_ownership(player, ball, hit)
end
ball.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
-- Assign possession
if player.Character:GetAttribute("CanGetBall") == false then return end
if not player.Character:GetAttribute(possessionTag) then
player.Character:SetAttribute(possessionTag, true) -- Mark the player as having the ball
ball.CanCollide = false
-- Attach ball to player for dribbling
AttachBallToPlayer(player, ball)
end
end
end)
Script To Change Height
local events = script.Parent.events
local Heights = {
["5'10\""] = 1.000,
["5'11\""] = 1.059,
["6'0\""] = 1.118,
["6'1\""] = 1.176,
["6'2\""] = 1.235,
["6'3\""] = 1.294,
["6'4\""] = 1.353,
["6'5\""] = 1.412,
["6'6\""] = 1.471,
["6'7\""] = 1.529,
["6'8\""] = 1.588,
["6'9\""] = 1.647,
["6'10\""] = 1.706,
["6'11\""] = 1.765,
["7'0\""] = 1.824,
["7'1\""] = 1.882,
["7'2\""] = 1.941,
["7'3\""] = 2.000,
}
events.Height.OnServerEvent:Connect(function(player, height)
local char = player.Character
local hum = char:WaitForChild("Humanoid")
hum:FindFirstChild("BodyHeightScale").Value = Heights[height]
end)