forked from MaximumADHD/Character-Realism
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRealism.server.lua
More file actions
53 lines (40 loc) · 1.75 KB
/
Realism.server.lua
File metadata and controls
53 lines (40 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- CloneTrooper1019, 2020
-- Realism Server
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CollectionService = game:GetService("CollectionService")
local setLookAngles = Instance.new("RemoteEvent")
setLookAngles.Archivable = false
setLookAngles.Name = "SetLookAngles"
setLookAngles.Parent = ReplicatedStorage
local function onReceiveLookAngles(player, pitch, yaw)
if typeof(pitch) ~= "number" or pitch ~= pitch then
return
end
if typeof(yaw) ~= "number" or yaw ~= yaw then
return
end
pitch = math.clamp(pitch, -1, 1)
yaw = math.clamp(yaw, -1, 1)
setLookAngles:FireAllClients(player, pitch, yaw)
end
local function onCharacterAdded(character)
local humanoid = character:WaitForChild("Humanoid", 10)
if humanoid and humanoid:IsA("Humanoid") then
CollectionService:AddTag(humanoid, "RealismHook")
end
end
local function onPlayerAdded(player)
if player.Character then
onCharacterAdded(player.Character)
end
player.CharacterAdded:Connect(onCharacterAdded)
end
for _,player in pairs(Players:GetPlayers()) do
onPlayerAdded(player)
end
Players.PlayerAdded:Connect(onPlayerAdded)
setLookAngles.OnServerEvent:Connect(onReceiveLookAngles)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------