Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Doors are not opening correctly via FireAllClient,any idea of what I am missing?

Asked by
Azuc 112
5 years ago
Edited 5 years ago

This is the script inside of the click detectors in the doors:

local Click = script.Parent
local Remotes = game:GetService("ReplicatedStorage"):WaitForChild("Remotes")

local State = false
local Debounce = true
local Modules = Remotes.Parent:WaitForChild("Modules").Doors
local Data = require(Modules:FindFirstChild(Click.Parent.Parent.Name))

local Handle = Click.Parent
local Body = Handle.Parent.Body
local Sound = script.Parent.Parent.Sound

local ClosedCF = Body.CFrame

Click.MouseClick:connect(function()
    if not Debounce then return end
    Debounce = false
    if State == false then
        State = true
        Remotes.DoorC:FireAllClients(Body.Parent, ClosedCF * Data.Offset, Data.Speed)
        Sound:Stop()
        Sound.Pitch = 0.8
        Sound:Play()
    elseif State == true then
        State = false
        Remotes.DoorC:FireAllClients(Body.Parent, ClosedCF, Data.Speed)
        Sound:Stop()
        Sound.Pitch = 1
        Sound:Play()
    end
    wait(1)
    Debounce = true
end)

Clicking the above should pull the info to fire from here (Script in replicated) however it is not working at all, it makes the sounds like its opening but never actually opens:

local m = {
Offset = CFrame.Angles(0,math.rad(-90),0) * CFrame.new(-2,0,-2.5);
Speed = 30; 
}

return m

Function:

function Lerp(target, cf, speed)
for i = 1,speed do
Render:wait()
if target:IsA("BasePart") then
target.CFrame = target.CFrame:lerp(cf, i/speed) 
elseif target:IsA("Model") then
target:SetPrimaryPartCFrame(target.PrimaryPart.CFrame:lerp(cf, i/speed))        
        end
    end 
return target.PrimaryPart.CFrame
end

game.ReplicatedStorage.DoorC.OnClientEvent:connect(function(Target, CF, Speed)
    local cf = Lerp(Target,CF,Speed)
end)

Answer this question