I am working on a script that adds a function to all parts tagged “DeathRegion” that stops the camera script for 2 seconds then resumes functioning as normal, the problem is that the remotefunction i use just yields infinitely for no reason
local cs = game:GetService("CollectionService")
wait(3)
local Parts = cs:GetTagged("DeathRegion")
local functions = {}
local db = false
local function PseudoDeath(Otherpa)
if db == false then
db = true
print("start")
if game:GetService("Players"):GetPlayerFromCharacter(Otherpa.Parent) then
print("yes")
local player = game:GetService("Players"):GetPlayerFromCharacter(Otherpa.Parent)
print("waiting")
local Camera = game.ReplicatedStorage.GetCameraScript:InvokeClient(player)
print("Done")
Camera.Disabled = true
print(Camera.Disabled)
wait(2)
Camera.Disabled = false
elseif Otherpa.Anchored == false then
wait(2)
Otherpa:Destroy()
end
db = false
end
end
for i , v in pairs(Parts) do
v.Touched:Connect(PseudoDeath)
end
The remote functon btw:
script.Parent.OnClientInvoke = function()
return game.Players.LocalPlayer.PlayerScripts.Cmera
end