0% found this document useful (0 votes)
44 views2 pages

Roblox Animation and Shadow Script

The document contains code for handling player character animations and interactions when touching walls or jumping in a game. It connects events like being touched, jumping, or dying to play animations or adjust velocities. It also includes code to create and position a shadow effect under the player character.

Uploaded by

hellwwk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views2 pages

Roblox Animation and Shadow Script

The document contains code for handling player character animations and interactions when touching walls or jumping in a game. It connects events like being touched, jumping, or dying to play animations or adjust velocities. It also includes code to create and position a shadow effect under the player character.

Uploaded by

hellwwk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

local hum = script.

Parent:WaitForChild("Humanoid")
local humRtPt = script.Parent:WaitForChild("HumanoidRootPart")
local animIDs = game.ReplicatedStorage:WaitForChild("AnimIDs")
local mainClientScript =
game.Players.LocalPlayer:WaitForChild("PlayerScripts"):WaitForChild("CL_MAIN_GameSc
ript")
local wallAnim = Instance.new("Animation")
wallAnim.AnimationId = "rbxassetid://" .. animIDs.WallHang.Value
local anim = hum:LoadAnimation(wallAnim)

hum.Touched:connect(function()
local notSwimming = hum:GetStateEnabled(Enum.HumanoidStateType.Jumping)
local state = hum:GetState()
if notSwimming and (state == Enum.HumanoidStateType.Jumping or state ==
Enum.HumanoidStateType.Freefall) then --Do the anchor
--Make ray to part, get normal
local ray = Ray.new(humRtPt.Position, ((humRtPt.Position +
humRtPt.CFrame.lookVector) - humRtPt.Position).unit * 2.5)
local part, pos, normal = workspace:FindPartOnRay(ray, script.Parent)
if part then
if part:FindFirstChild("_Wall") then
humRtPt.Anchored = true
humRtPt.CFrame = CFrame.new(humRtPt.Position,
humRtPt.Position + normal)
anim:Play()
local begin = tick()
local jumped
spawn(function()
game:GetService("UserInputService").JumpRequest:wait(); if begin < tick() + .75
then jumped = true end end)
repeat wait()
until jumped or tick() > begin + .75
anim:Stop()
humRtPt.Anchored = false
if jumped then
humRtPt.Velocity = Vector3.new(normal.X * 50, 50 +
(normal.Y * 50), normal.Z * 50)
else
humRtPt.Velocity = Vector3.new()
end
end

end
end
end)

--Reliable Jump Velocities, no baby jumps like other games

hum.Jumping:connect(function(isJumping)
if isJumping then
humRtPt.Velocity = Vector3.new(humRtPt.Velocity.X, hum.JumpPower * 1.1,
humRtPt.Velocity.Z)
end
end)

--Drop shadow code

local shadow = workspace.CurrentCamera:FindFirstChild("ShadowPt")


if not shadow then
shadow = Instance.new("Part")
shadow.Size = Vector3.new(4, .05, 4)
shadow.Transparency = 1
shadow.CanCollide = false
shadow.Anchored = true
shadow.Material = Enum.Material.Concrete
shadow.Name = "ShadowPt"

local decal = Instance.new("Decal")


decal.Texture = "rbxassetid://1057492965"
decal.Face = "Top"
decal.Name = "ShadowImg"
decal.Transparency = .5
decal.Parent = shadow
shadow.Parent = workspace.CurrentCamera
else
shadow.ShadowImg.Transparency = .5 -- I return lol
end

hum.Died:connect(function()
if shadow then
shadow.ShadowImg.Transparency = 1
end
end)

local ignoreList = {shadow, script.Parent}

workspace.ChildAdded:connect(function(item) --Ignore other chars


if game.Players:FindFirstChild(item.Name) then
table.insert(ignoreList, item)
end
end)

for _,c in pairs(game.Players:GetPlayers()) do


if c.Character then
table.insert(ignoreList, c.Character)
end
end

while game:GetService("RunService").Heartbeat:wait() do
--Drop Shadow
local ray = Ray.new(humRtPt.Position, Vector3.new(0, -300, 0))
local ignore = {shadow, script.Parent}
local part, pos, normal = workspace:FindPartOnRayWithIgnoreList(ray, ignore)
if pos then
shadow.CFrame = CFrame.new(pos)
end
end

You might also like