I am making a survival game and a player is chosen to be a killer, I made it so that the script should make the camera follow the character but it doesn’t work. It doesn’t even print “Camera” in the output. Can someone help me on how to fix this?
Localscript:
local player = game.Players.LocalPlayer
repeat wait() until player.CharacterAdded
local mouse = player:GetMouse()
local Killer = game.ReplicatedStorage.Killers.CampingGuy
local hit = Killer:WaitForChild("Swing")
local character = player.Character
local humanoid = character:WaitForChild("Humanoid",5)
local animator = humanoid:FindFirstChildOfClass("Animator")
local hitAnim = animator:LoadAnimation(hit)
local Events = game.ReplicatedStorage:WaitForChild("Events")
local debounce = false
local disabled = true
player.Killer.Changed:Connect(function()
if player.Killer.Value == true then
disabled = false
Events.Killerify:FireServer()
wait(0.5)
else
disabled = true
print(player.Name.." is no longer the killer")
end
end)
Events.KillerCamera.OnClientEvent:Connect(function(Morph)
local camera = workspace.CurrentCamera
camera.CameraSubject = Morph.Humanoid
print("Camera")
end)
mouse.Button1Down:Connect(function()
if not debounce and disabled == false then
debounce = true
hitAnim:Play()
local damage = 50
Events.HitEvent:FireServer(damage)
wait(1.5)
debounce = false
end
end)
Serverscript:
local Events = game.ReplicatedStorage:WaitForChild("Events")
game.Players.PlayerAdded:Connect(function(player)
local v = Instance.new("BoolValue")
v.Name = "Playing"
v.Parent = player
local v1 = Instance.new("BoolValue")
v1.Name = "Killer"
v1.Parent = player
player:SetAttribute("Killer", false)
end)
Events.HitEvent.OnServerEvent:Connect(function(player, damage)
local sounds = player.Character.Sounds
local hitsound = sounds["knife swing"]:Clone()
hitsound.Parent = player.Character.Head
hitsound:Play()
repeat wait() until hitsound.Playing == false
hitsound:Destroy()
for i,target in pairs(game.Workspace:GetDescendants()) do
if target:IsA("Humanoid") and target.Parent.Name ~= player.Name and not target.Parent:FindFirstChild("Zombie") then
if (target.Parent.HumanoidRootPart.Position - player.Character.HumanoidRootPart.Position).magnitude < 5 then
target.Parent.Humanoid.Health -= damage
local sounds = player.Character.Sounds
local hitsound = sounds["Knife Stab 1"]:Clone()
hitsound.Parent = player.Character.Head
hitsound:Play()
repeat wait() until hitsound.Playing == false
hitsound:Destroy()
end
end
end
end)
Events.Killerify.OnServerEvent:Connect(function(player)
local Model = game.ReplicatedStorage.Killers.CampingGuy
local Morph = Model:Clone()
Morph.Parent = workspace
Morph:MoveTo(player.Character.Torso.Position)
Morph.Name = player.Name
player.Character = Morph
Events.KillerCamera:FireClient(player, Morph)
print(player.Name.." is the killer")
end)