local SETTINGS = {
ArmColor = owner.Character["Left Arm"].Color;
LegColor = owner.Character["Left Leg"].Color;
TorsoColor = owner.Character.Torso.Color;
Material = Enum.Material.SmoothPlastic;
Gravity = 120;
AdaptToWorkspaceGravity = true;
}
if SETTINGS.AdaptToWorkspaceGravity == true then
SETTINGS.Gravity = workspace.Gravity
workspace:GetPropertyChangedSignal("Gravity"):Connect(function()
SETTINGS.Gravity = workspace.Gravity
end)
end
local clothingPos = {
["t"] = {
[1] = {Vector2.new(128, 129), Vector2.new(231, 73)};
[2] = {Vector2.new(128, 129), Vector2.new(427, 73)};
[3] = {Vector2.new(128, 65), Vector2.new(231, 7)};
[4] = {Vector2.new(128, 65), Vector2.new(231, 203)};
[5] = {Vector2.new(64, 129), Vector2.new(165, 73)};
[6] = {Vector2.new(64, 129), Vector2.new(361, 73)}
};
["la"] = {
[1] = {Vector2.new(64, 128), Vector2.new(217, 355)};
[2] = {Vector2.new(64, 128), Vector2.new(85, 355)};
[3] = {Vector2.new(64, 64), Vector2.new(217, 289)};
[4] = {Vector2.new(64, 64), Vector2.new(217, 485)};
[5] = {Vector2.new(64, 128), Vector2.new(19, 355)};
[6] = {Vector2.new(64, 128), Vector2.new(151, 355)}
};
["ra"] = {
[1] = {Vector2.new(64, 128), Vector2.new(307, 355)};
[2] = {Vector2.new(64, 128), Vector2.new(440, 355)};
[3] = {Vector2.new(64, 64), Vector2.new(308, 289)};
[4] = {Vector2.new(64, 64), Vector2.new(308, 485)};
[5] = {Vector2.new(64, 128), Vector2.new(374, 355)};
[6] = {Vector2.new(64, 128), Vector2.new(506, 355)}
};
["ll"] = {
[1] = {Vector2.new(64, 128), Vector2.new(217, 355)};
[2] = {Vector2.new(64, 128), Vector2.new(85, 355)};
[3] = {Vector2.new(64, 64), Vector2.new(217, 289)};
[4] = {Vector2.new(64, 64), Vector2.new(217, 485)};
[5] = {Vector2.new(64, 128), Vector2.new(19, 355)};
[6] = {Vector2.new(64, 128), Vector2.new(151, 355)}
};
["rl"] = {
[1] = {Vector2.new(64, 128), Vector2.new(307, 355)};
[2] = {Vector2.new(64, 128), Vector2.new(440, 355)};
[3] = {Vector2.new(64, 64), Vector2.new(308, 289)};
[4] = {Vector2.new(64, 64), Vector2.new(308, 485)};
[5] = {Vector2.new(64, 128), Vector2.new(374, 355)};
[6] = {Vector2.new(64, 128), Vector2.new(506, 355)}
}
}
local surfaceFace = {
[1] = Enum.NormalId.Front;
[2] = Enum.NormalId.Back;
[3] = Enum.NormalId.Top;
[4] = Enum.NormalId.Bottom;
[5] = Enum.NormalId.Left;
[6] = Enum.NormalId.Right
}
function createClothing(model)
for _, v in pairs(model:GetChildren()) do
if v.Name ~= "h" and v.Name ~= "r" and v:IsA("BasePart") then
for p = 1, 6 do
local surfaceGui = Instance.new("SurfaceGui")
surfaceGui.Face = surfaceFace[p]
surfaceGui.Parent = v
local clothing = Instance.new("ImageLabel")
clothing.Size = UDim2.new(1, 0, 1, 0)
clothing.LightingInfluence = 1
clothing.ImageRectSize = clothingPos[v.Name][p][1]
clothing.ImageRectOffset = clothingPos[v.Name][p][2]
if v.Name == "ll" or v.Name == "rl" then
clothing.Image = owner.Character.Pants.PantsTemplate
else
clothing.Image = owner.Character.Shirt.ShirtTemplate
end
clothing.BackgroundTransparency = 1
clothing.BorderSizePixel = 0
clothing.Parent = surfaceGui
end
end
end
end
local function DarkenColor(colorRGB, amount)
return Color3.fromRGB(colorRGB.R + amount, colorRGB.G + amount, colorRGB.B + amount)
end
local function Lerp(a, b, t)
return a * (1 - t) + (b * t)
end
local function IsInWater(pos)
local region = Region3.new(pos - Vector3.one*4, pos + Vector3.one*4)
return workspace.Terrain:ReadVoxels(region, 4)[1][1][1] == Enum.Material.Water
end
script.Name = "wowbowcow" .. owner.Name
local hum = owner.Character:FindFirstChildWhichIsA("Humanoid")
owner.Character.Parent = game:GetService("Lighting")
local root, head, torso, larm, rarm, lleg, rleg
local billboard, tecks
local limbTemplate = Instance.new("Part")
limbTemplate.Size = Vector3.new(1, 1, 1)
limbTemplate.Anchored = true
limbTemplate.CanCollide = false
limbTemplate.CanQuery = false
limbTemplate.Material = SETTINGS.Material
local limbMeshTemplate = Instance.new("SpecialMesh")
limbMeshTemplate.MeshType = Enum.MeshType.Head
limbMeshTemplate.MeshId = "rbxassetid://5062992824"
local clothingPos = {
["shirt"] = {
["torso"] = {
[1] = {Vector2.new(128, 129), Vector2.new(231, 73)};
[2] = {Vector2.new(128, 129), Vector2.new(427, 73)};
[3] = {Vector2.new(128, 65), Vector2.new(231, 7)};
[4] = {Vector2.new(128, 65), Vector2.new(231, 203)};
[5] = {Vector2.new(64, 129), Vector2.new(165, 73)};
[6] = {Vector2.new(64, 129), Vector2.new(361, 73)};
}
}
}
local surfaceFace = {
[1] = Enum.NormalId.Front;
[2] = Enum.NormalId.Back;
[3] = Enum.NormalId.Top;
[4] = Enum.NormalId.Bottom;
[5] = Enum.NormalId.Left;
[6] = Enum.NormalId.Right
}
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.IgnoreWater = true
raycastParams.FilterDescendantsInstances = {script}
local previousCF = owner.Character.HumanoidRootPart.CFrame
local function createCharacter()
local fakeChar = Instance.new("Model")
fakeChar.Name = "fakeChar" ..owner.Name
fakeChar.Parent = script
root = limbTemplate:Clone()
root.Size = Vector3.new(2, 2, 1)
root.Transparency = 1
root.Name = "r"
root.Parent = fakeChar
billboard = Instance.new("BillboardGui")
billboard.Adornee = root
billboard.ExtentsOffsetWorldSpace = Vector3.new(0, 3.2, 0)
billboard.Name = "Nametag"
billboard.Size = UDim2.new(4, 0, 1, 0)
billboard.Parent = root
tecks = Instance.new("TextLabel")
tecks.Text = owner.Name
tecks.Font = Enum.Font.Ubuntu
tecks.Size = UDim2.new(1, 0, 1, 0)
tecks.TextScaled, tecks.TextWrapped = true, true
tecks.BackgroundTransparency = 1
tecks.TextStrokeTransparency = 0
tecks.TextStrokeColor3 = Color3.new()
tecks.TextColor3 = Color3.new(1, 1, 1)
tecks.Parent = billboard
torso = limbTemplate:Clone()
torso.Color = SETTINGS.TorsoColor
torso.Size = Vector3.new(2, 2, 1)
torso.Name = "t"
torso.Parent = fakeChar
local spesh = limbMeshTemplate:Clone()
spesh.Scale = Vector3.new(2, 1, 1)
spesh.Parent = torso
head = limbTemplate:Clone()
head.Name = "h"
head.Color = SETTINGS.ArmColor
head.CFrame = torso.CFrame * CFrame.new(0, 1.5, 0)
head.Parent = fakeChar
local spesh = Instance.new("SpecialMesh")
spesh.MeshType = Enum.MeshType.Head
spesh.Scale = Vector3.new(1.25, 1.25, 1.25)
spesh.Parent = head
local deckle = Instance.new("Decal")
deckle.Name = "face"
deckle.Texture = owner.Character.Head.face.Texture
deckle.Face = Enum.NormalId.Front
deckle.Parent = head
larm = limbTemplate:Clone()
larm.Size = Vector3.new(1, 2, 1)
larm.Name = "la"
larm.Color = SETTINGS.ArmColor
larm.CFrame = torso.CFrame * CFrame.new(-1.5, 0, 0)
larm.Parent = fakeChar
rarm = limbTemplate:Clone()
rarm.Size = Vector3.new(1, 2, 1)
rarm.Name = "ra"
rarm.Color = SETTINGS.ArmColor
rarm.CFrame = torso.CFrame * CFrame.new(1.5, 0, 0)
rarm.Parent = fakeChar
lleg = limbTemplate:Clone()
lleg.Size = Vector3.new(1, 2, 1)
lleg.Name = "ll"
lleg.Color = SETTINGS.LegColor
lleg.CFrame = torso.CFrame * CFrame.new(-0.5, -2, 0)
lleg.Parent = fakeChar
rleg = limbTemplate:Clone()
rleg.Size = Vector3.new(1, 2, 1)
rleg.Name = "rl"
rleg.Color = SETTINGS.LegColor
rleg.CFrame = torso.CFrame * CFrame.new(0.5, -2, 0)
rleg.Parent = fakeChar
limbMeshTemplate:Clone().Parent = larm
limbMeshTemplate:Clone().Parent = rarm
limbMeshTemplate:Clone().Parent = lleg
limbMeshTemplate:Clone().Parent = rleg
for _, v in pairs(owner.Character:GetChildren()) do
if v:IsA("Accessory") or v:IsA("Hat") then
local cloneThing = v:Clone()
cloneThing.Parent = fakeChar
local cloneHandle = cloneThing:FindFirstChildWhichIsA("BasePart")
local cloneWeld = cloneHandle:FindFirstChildWhichIsA("Weld")
if cloneWeld.Part1.Name == "Head" then
cloneWeld.Part1 = head
elseif cloneWeld.Part1.Name == "Torso" then
cloneWeld.Part1 = torso
end
end
end
createClothing(fakeChar)
root.CFrame = previousCF --* CFrame.new(0, 4000, 0)
for _, p in pairs(script:GetChildren()) do
if p:IsA("BasePart") then
local conn; conn = p:GetPropertyChangedSignal("Parent"):Connect(function(parent)
if parent == nil then
do
for _, p in pairs(script:GetChildren()) do
if p:IsA("BasePart") then
p:Destroy()
end
end
end
createCharacter()
conn:Disconnect()
end
end)
end
end
print("created new character for " .. owner.Name)
end
createCharacter()
local speed = 1
local waterSpeedMult = 0.5
local fallTime = 0
local t = 0
local gravity = SETTINGS.Gravity
local translateVector = Vector3.new()
local mouseCF = CFrame.new()
local floor = false
local faceMouse = false
local function applyNormalToChar(hit, normal)
local invertedNorm = Vector3.new(-math.abs(normal.X), 0, -math.abs(normal.Z))
if hit and hit.CanCollide and not hit.Parent:IsA("Accessory") then
root.Position += (invertedNorm * translateVector)
end
end
game:GetService("RunService").Heartbeat:Connect(function(dt)
if script then
if hum.Jump and floor then
fallTime = -0.36 -- so hacky lmao
end
previousCF = root.CFrame
root.Position += translateVector
local dy = Vector3.yAxis * dt * ((-gravity/2) * dt - gravity * fallTime)
do -- floor and ceiling collision
local rayDown = workspace:Raycast(root.Position, root.CFrame.UpVector * -3 + dy, raycastParams)
if rayDown then
local hit, pos = rayDown.Instance, rayDown.Position
if hit then
if hit.CanCollide then
floor = true
fallTime = 0
root.Position = Vector3.new(root.Position.X, pos.Y + 3, root.Position.Z)
if hit.Velocity.Magnitude > 0 then
root.Position += hit.Velocity / 60
end
else
floor = false
root.Position += dy
end
end
else
floor = false
root.Position += dy
end
local rayUp = workspace:Raycast(root.Position, root.CFrame.UpVector * 2, raycastParams)
if rayUp then
local hit, pos = rayUp.Instance, rayUp.Position
if hit then
if hit.CanCollide then
fallTime = 0
root.Position += Vector3.new(0, -0.1, 0)
end
end
end
fallTime += dt
end
do -- wall collision
for x = 1, 4 do
for y = 1, 4 do
local offset = Vector3.new(-1 + (x / 2), 1 - (y/2), 0)
local p1, p2 = root.Position + offset, (root.CFrame * CFrame.new(0, offset.Y, 0))
local rayFwd = workspace:Raycast(p1, p2.LookVector * 0.52 * speed, raycastParams)
if rayFwd then
local hit, pos, norm = rayFwd.Instance, rayFwd.Position, rayFwd.Normal
applyNormalToChar(hit, norm)
end
local rayBack = workspace:Raycast(p1, p2.LookVector * -0.52 * speed, raycastParams)
if rayBack then
local hit, pos, norm = rayBack.Instance, rayBack.Position, rayBack.Normal
applyNormalToChar(hit, norm)
end
local rayLeft = workspace:Raycast(p1, p2.RightVector * -0.52 * speed, raycastParams)
if rayLeft then
local hit, pos, norm = rayLeft.Instance, rayLeft.Position, rayLeft.Normal
applyNormalToChar(hit, norm)
end
local rayRight = workspace:Raycast(p1, p2.RightVector * 0.52 * speed, raycastParams)
if rayRight then
local hit, pos, norm = rayRight.Instance, rayRight.Position, rayRight.Normal
applyNormalToChar(hit, norm)
end -- Wot to flip?? Not optimized dude!
end
end
end
if hum.MoveDirection.Magnitude > 0.5 then
if not faceMouse then
root.CFrame = root.CFrame:Lerp(CFrame.lookAt(root.Position, root.Position + hum.MoveDirection), 0.2 * dt * 60)
end
translateVector = translateVector:Lerp((hum.MoveDirection / 3) * speed * (IsInWater(root.Position) and waterSpeedMult or 1), 0.2 * dt * 60)
else
local alpha = math.abs(fallTime) > 0.02 and 0.02 or 0.16
translateVector = translateVector:Lerp(Vector3.zero, alpha * dt * 60)
end
if faceMouse then
root.CFrame = CFrame.lookAt(root.Position, mouseCF.p * Vector3.new(1, 0, 1))
end
do -- animations
if fallTime < -0.02 then -- jump
t += 0.5
torso.CFrame = root.CFrame
larm.CFrame = torso.CFrame *
CFrame.new(-1.5, 0, 0) *
CFrame.new(0, 0.5, 0) *
CFrame.new(0, 0.1, 0.07) *
CFrame.Angles(math.rad(3) + math.sin(t / 8) / 15, -math.rad(12), -math.rad(9)) *
CFrame.new(0, -0.5, 0)
rarm.CFrame = torso.CFrame *
CFrame.new(1.5, 0, 0) *
CFrame.new(0, 0.5, 0) *
CFrame.new(0, 0.1, 0.07) *
CFrame.Angles(math.rad(7) + math.cos(t / 8) / 15, math.rad(15), math.rad(9)) *
CFrame.new(0, -0.5, 0)
lleg.CFrame = torso.CFrame *
CFrame.new(-0.5, -2, 0) *
CFrame.new(0, 0.5, 0) *
CFrame.new(0, 0.5, -0.4) *
CFrame.Angles(-math.rad(26), math.rad(5), -math.rad(2)) *
CFrame.new(0, -0.5, 0)
rleg.CFrame = torso.CFrame *
CFrame.new(0.5, -2, 0) *
CFrame.new(0, 0.5, 0) *
CFrame.new(0, 0.03, -0.07) *
CFrame.Angles(-math.rad(8), 0, math.rad(3)) *
CFrame.new(0, -0.5, 0)
elseif fallTime > 0.05 then -- fall
t += 0.3
torso.CFrame = root.CFrame *
CFrame.Angles(-math.sin(math.cos(t / 3) / 6) / 8, 0, 0)
larm.CFrame = torso.CFrame *
CFrame.new(-1.5, 0, 0) *
CFrame.new(0, 0.5, 0) *
CFrame.new(0, 0.23 + math.sin(t / 3) / 22 - math.cos(t / 1.5) / 25, 0.15 + math.sin(t / 3) / 30) *
CFrame.Angles(-math.rad(7) - math.cos(t / 3) / 18, 0, 0) *
CFrame.Angles(0, -math.rad(7), -math.rad(82) - math.sin(t / 3) / 7 - math.cos(t / 1.5) / 20) *
CFrame.new(0, -0.5, 0)
rarm.CFrame = torso.CFrame *
CFrame.new(1.5, 0, 0) *
CFrame.new(0, 0.5, 0) *
CFrame.new(0, 0.23 + math.sin(t / 3) / 22 - math.cos(t / 1.5) / 25, 0.15 + math.sin(t / 3) / 30) *
CFrame.Angles(-math.rad(7) + math.cos(t / 3) / 18, 0, 0) *
CFrame.Angles(0, math.rad(7), math.rad(82) + math.sin(t / 3) / 7 + math.cos(t / 1.5) / 20) *
CFrame.new(0, -0.5, 0)
lleg.CFrame = torso.CFrame *
CFrame.new(-0.5, -2, 0) *
CFrame.new(0, 0.5, 0) *
CFrame.new(0, 0.1 + math.sin(math.cos(t / 4) / 4) / 8, -0.07) *
CFrame.Angles(-math.rad(5) + math.cos(t / 3) / 20 + math.sin(t / 1.5) / 20, 0, -math.rad(4)) *
CFrame.new(0, -0.5, 0)
rleg.CFrame = torso.CFrame *
CFrame.new(0.5, -2, 0) *
CFrame.new(0, 0.5, 0) *
CFrame.new(0, 0.2 - math.sin(math.cos(t / 2) / 4) / 8, -0.1) *
CFrame.Angles(-math.rad(5) - math.cos(t / 3) / 20 + math.sin(t / 1.5) / 15, 0, math.rad(3)) *
CFrame.new(0, -0.5, 0)
else
t += 0.5 * speed
if hum.MoveDirection.Magnitude > 0.5 then -- walk
torso.CFrame = root.CFrame *
CFrame.new(0, math.clamp(-math.sin(t) / 15, 0, 5), 0) *
CFrame.Angles(-math.rad(2) + math.cos(t) / 30, -math.sin(t / 2) / 30, 0)
larm.CFrame = torso.CFrame *
CFrame.new(-1.5, 0, 0) *
CFrame.new(0, 0.5, 0) *
CFrame.Angles(-math.sin(t / 2) / 1.3, 0, 0) *
CFrame.new(0, -0.5, 0)
rarm.CFrame = torso.CFrame *
CFrame.new(1.5, 0, 0) *
CFrame.new(0, 0.5, 0) *
CFrame.Angles(math.sin(t / 2) / 1.3, 0, 0) *
CFrame.new(0, -0.5, 0)
lleg.CFrame = torso.CFrame *
CFrame.new(-0.5, -2, 0) *
CFrame.new(0, 0.5, 0) *
CFrame.Angles(0, math.rad(1), 0) *
CFrame.Angles(-math.rad(11) + math.sin(t / 2) / 2 - math.cos(t / 2) / 2, -math.sin(t / 2) / 15, 0) *
CFrame.new(0, math.clamp(math.cos(t / 2) / 1.5, 0, 1), 0.2 + math.clamp(-math.sin(t / 2) / 1.3, -1, 0.2)) *
CFrame.new(0, -0.5, 0)
rleg.CFrame = torso.CFrame *
CFrame.new(0.5, -2, 0) *
CFrame.new(0, 0.5, 0) *
CFrame.Angles(0, -math.rad(1), 0) *
CFrame.Angles(-math.rad(11) + -math.sin(t / 2) / 2 + math.cos(t / 2) / 2, -math.sin(t / 2) / 15, 0) *
CFrame.new(0, math.clamp(-math.cos(t / 2) / 1.5, 0, 1), 0.2 + math.clamp(math.sin(t / 2) / 1.3, -1, 0.2)) *
CFrame.new(0, -0.5, 0)
else -- idle
torso.CFrame = root.CFrame
larm.CFrame = torso.CFrame *
CFrame.new(-1.5, 0, 0) *
CFrame.new(0, 0.5, 0) *
CFrame.Angles(0, math.rad(2) + math.sin(t / 20) / 25, -math.rad(2) + math.cos(t / 20) / 35) *
CFrame.new(0, -0.5, 0)
rarm.CFrame = torso.CFrame *
CFrame.new(1.5, 0, 0) *
CFrame.new(0, 0.5, 0) *
CFrame.Angles(0, -math.rad(2) - math.sin(t / 20) / 25, math.rad(2) - math.cos(t / 20) / 35) *
CFrame.new(0, -0.5, 0)
lleg.CFrame = torso.CFrame * CFrame.new(-0.5, -2, 0)
rleg.CFrame = torso.CFrame * CFrame.new(0.5, -2, 0)
end
end
end
local dist = (head.Position - mouseCF.p).Magnitude
local diff = head.CFrame.Y - mouseCF.Y
local unit = (head.Position - mouseCF.p).Unit
head.CFrame = torso.CFrame *
CFrame.new(0, 1.5, 0) *
CFrame.new(0, -0.5, 0) *
CFrame.Angles(-math.asin(diff / dist) * 0.7, unit:Cross(torso.CFrame.LookVector).Y * 0.75, 0) *
CFrame.new(0, 0.5, 0)
end
end)
local remote = Instance.new("RemoteEvent")
remote.Name = "argh"
remote.Parent = fakeChar
task.spawn(function()
while true do
local plr, argument = remote.OnServerEvent:Wait()
if plr == owner then
if argument and typeof(argument) == "CFrame" then
mouseCF = argument
elseif typeof(argument) == "string" then
if argument == "sprint" then
speed = 1.8
elseif argument == "walk" then
speed = 1
elseif argument == "faceMouse" then
faceMouse = not faceMouse
print("Character follows mouse: " .. tostring(faceMouse))
end
end
end
end
end)
NLS([[
local UIS = game:GetService("UserInputService")
local mouse = owner:GetMouse()
mouse.TargetFilter = workspace
local s = workspace:FindFirstChild("wowbowcow" .. owner.Name)
local fc = s:FindFirstChild("fakeChar" .. owner.Name)
workspace.CurrentCamera.CameraSubject = fc:WaitForChild("h")
s.ChildAdded:Connect(function(ch)
if ch.Name == "h" then
workspace.CurrentCamera.CameraSubject = ch
end
end)
local remote = s:WaitForChild("argh")
UIS.InputBegan:Connect(function(input, gameProcessed)
if not gameProcessed then
if input.KeyCode == Enum.KeyCode.LeftControl then
remote:FireServer("sprint")
elseif input.KeyCode == Enum.KeyCode.N then
remote:FireServer("faceMouse")
end
end
end)
UIS.InputEnded:Connect(function(input, gameProcessed)
if not gameProcessed then
if input.KeyCode == Enum.KeyCode.LeftControl then
remote:FireServer("walk")
end
end
end)
while task.wait() do
remote:FireServer(mouse.Hit)
end]], owner.PlayerGui)