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

Having Issues with functions inside of a server remote function?

Asked by 5 years ago
Edited 5 years ago

I am working on a press "e" to open door script, the client part is finished though the server is not. I'm not very good with remote functions so that might be why but here is the script:

    local func = game.ReplicatedStorage.door

local event = game.ReplicatedStorage.openDoor

local d = game.Workspace.Doors

local TweenService = game:GetService("TweenService")

local module = require(game.ServerScriptService.GroupRanks)

local groupId = module.gId

local minroleId = module.rank





func.OnServerInvoke = function(player,ID)

print("1")

local Door = d:FindFirstChild(ID)

local Scripted = Door:WaitForChild("ScriptedComponents")

local SettingsModule = require(Door:WaitForChild("Settings"))

local Teams = SettingsModule.Teams

local opening = Door:WaitForChild("opening")

local LockValue = Door:WaitForChild("perm")

local Door1 = Scripted:WaitForChild("Door1")

local Door2 = Scripted:WaitForChild("Door2")

local hm = false

local opened = false

local debounce = false

local scanDebounce = false

local openTime = 2.5

local closeTime = 2.5



Settings = {

waitTime = 5,

Tweening = {

openInfo = TweenInfo.new(openTime,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),

closeInfo = TweenInfo.new(closeTime,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),

Door1Close = { CFrame = Door1.CFrame * CFrame.new(0,0,0) },

Door2Close = { CFrame = Door2.CFrame * CFrame.new(0,0,0) },

Door1Open = { CFrame = Door1.CFrame * CFrame.new(0,0,2.8) },

Door2Open = { CFrame = Door2.CFrame * CFrame.new(0,0,-2.8) }

}

}

print("2")

function OpenDoor()

print("0.1")

if not debounce then

print("0.2")

if not opened then

print("0.3")

if not hm then

print("0.4")

debounce = true

local Door1Open = TweenService:Create(Door1,Settings.Tweening.openInfo,Settings.Tweening.Door1Open)

local Door2Open = TweenService:Create(Door2,Settings.Tweening.openInfo,Settings.Tweening.Door2Open)

Door1Open:Play()

Door2Open:Play()

hm = true

Door1.Open:Play()

print("3")

wait(openTime)

opened = true

wait(Settings.waitTime - openTime)

debounce = false

hm = false

if LockValue.Value == false then

OpenDoor() --Automatically close door

end

print("4")

else

debounce = true

print("5")

local Door1Close = TweenService:Create(Door1,Settings.Tweening.closeInfo,Settings.Tweening.Door1Close)

local Door2Close = TweenService:Create(Door2,Settings.Tweening.closeInfo,Settings.Tweening.Door2Close)

Door2Close:Play()

Door1Close:Play()

Door1.Close:Play()

hm = true

wait(closeTime)

opened = false

debounce = false

hm = false

end

end

end

for i,v in pairs(Teams) do

if player.TeamColor == game:GetService("Teams"):FindFirstChild(v).TeamColor or player:GetRankInGroup(groupId) >= minroleId then

local IDD = ID

local granted = "yes"

print("yes")

event:FireClient(player,granted,IDD)

OpenDoor()

else

local IDD = ID

local granted = "no"

print("no")

wait()

event:FireClient(player,granted,IDD)

wait(4)

end

end

end

end

When I run and press E on the door it prints 1, then 2. Nothing more than that? It should be running through the entire OpenDoor() function. Is there something I'm missing or forgot? Any help would be appreciated. Thanks!

0
This code is very messy, do please indent, also why are you defining constants inside the function ? User#24403 69 — 5y

Answer this question