-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathRealism.server.lua
More file actions
49 lines (38 loc) · 1.7 KB
/
Realism.server.lua
File metadata and controls
49 lines (38 loc) · 1.7 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
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- MaximumADHD, 2020
-- Realism Server
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--!strict
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local setLookAngles = Instance.new("RemoteEvent")
setLookAngles.Archivable = false
setLookAngles.Name = "SetLookAngles"
setLookAngles.Parent = ReplicatedStorage
local function onReceiveLookAngles(player: Player, pitch: number, yaw: number)
if type(pitch) == "number" and pitch == pitch then
pitch = math.clamp(pitch, -1, 1)
if type(yaw) == "number" and yaw == yaw then
yaw = math.clamp(yaw, -1, 1)
setLookAngles:FireAllClients(player, pitch, yaw)
end
end
end
local function onCharacterAdded(character: Model)
local humanoid = character:WaitForChild("Humanoid", 10)
if humanoid and humanoid:IsA("Humanoid") then
humanoid:AddTag("RealismHook")
end
end
local function onPlayerAdded(player: Player)
player.CharacterAdded:Connect(onCharacterAdded)
if player.Character then
task.spawn(onCharacterAdded, player.Character)
end
end
Players.PlayerAdded:Connect(onPlayerAdded)
setLookAngles.OnServerEvent:Connect(onReceiveLookAngles)
for _, player in Players:GetPlayers() do
onPlayerAdded(player)
end
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------