Hello there! I'm currently programming an Object Oriented Elevator which uses Collection Service. The client-sided script of the elevator is located in StarterPlayerScripts and utilizes UserInputService as well as CollectionService, however, there is a problem. The client is returning the proper value (done with a print), while the server script is receiving the parent of the parent of the parent of the value instead of the value itself. The communication takes place via a remote event.
Here, you can see my output
CLIENT-SIDED CODE:
-- Services
local RunService = game:GetService("RunService")
local PlayerService = game:GetService("Players")
local CollectionService = game:GetService("CollectionService")
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Overture = require(ReplicatedStorage:WaitForChild("Overture", 3))
local Maid = Overture:LoadLibrary("Maid")
local sPlayers = Overture:LoadLibrary("sPlayers")
local sFunctions = Overture:LoadLibrary("sFunctions")
-- Variables
local Retrieve = sFunctions.Retrieve
local IsInTable = sFunctions.IsInTable
local Player = PlayerService.LocalPlayer
local ElevatorReplication = Overture:GetRemoteEvent("ElevatorReplication")
local IsClient = RunService:IsClient()
local IsServer = RunService:IsServer()
local Distance = 7
-- Main Code
--for index, elevator in pairs(CollectionService:GetTagged("Elevator")) do
-- if elevator:IsA("Model") then
-- UserInputService.InputBegan:Connect(function(input, gameprocessed)
-- if input.KeyCode == Enum.KeyCode.E then
-- for index, button in pairs(CollectionService:GetTagged("ElevatorButton")) do
-- local ButtonPart = button.ButtonPart
-- local Magnitude = (ButtonPart.Position - Player.Character.HumanoidRootPart.Position).magnitude
-- local Configuration = elevator:WaitForChild("Configuration", 5)
-- local FloorNumber = Configuration.FloorNumber.Value
-- local floorValue = ButtonPart.FloorValue.Value
-- local Moving = Retrieve("Moving", "BoolValue", Configuration)
-- if Magnitude <= Distance then
-- ButtonPart.Accepted:Play()
-- ElevatorReplication:FireServer(floorValue, "Up", elevator)
-- if FloorNumber > floorValue then
-- ElevatorReplication:FireServer(floorValue, "Up", elevator)
-- elseif FloorNumber < floorValue then
-- ElevatorReplication:FireServer(floorValue, "Down", elevator)
-- elseif FloorNumber == floorValue then
-- ElevatorReplication:FireServer(floorValue, "X", elevator)
-- end
-- end
-- end
-- end
-- end)
-- end
--end
for index, elevator in pairs(CollectionService:GetTagged("Elevator")) do
if elevator:IsA("Model") then
for index, button in pairs(CollectionService:GetTagged("ElevatorButton")) do
local ButtonPart = button.ButtonPart
local Configuration = elevator:WaitForChild("Configuration", 5)
local FloorNumber = Configuration.FloorNumber.Value
local floorValue = ButtonPart.FloorValue.Value
local Moving = Retrieve("Moving", "BoolValue", Configuration)
UserInputService.InputBegan:Connect(function(input, gameprocessed)
if input.KeyCode == Enum.KeyCode.E then
local Magnitude = (ButtonPart.Position - Player.Character.HumanoidRootPart.Position).magnitude
if Magnitude <= Distance then
ButtonPart.Accepted:Play()
if floorValue == 0 then
ElevatorReplication:FireServer(elevator, 0)
elseif floorValue == 1 then
ElevatorReplication:FireServer(elevator, 1)
elseif floorValue == 2 then
ElevatorReplication:FireServer(elevator, 2)
elseif floorValue == 3 then
ElevatorReplication:FireServer(elevator, 3)
elseif floorValue == 4 then
ElevatorReplication:FireServer(elevator, 4)
elseif floorValue == 5 then
ElevatorReplication:FireServer(elevator, 5)
end
end
end
end)
end
end
end
SERVER-SIDED CODE (RELEVANT ONLY):
-- Services
local PlayerService = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CollectionService = game:GetService("CollectionService")
local Overture = require(ReplicatedStorage:WaitForChild("Overture", 3))
local ElevatorClass = Overture:LoadClass("Elevator")
local sPlayers = Overture:LoadLibrary("sPlayers")
local sFunctions = Overture:LoadLibrary("sFunctions")
-- Variables
local Retrieve = sFunctions.Retrieve
local Elevators = {}
local IsInTable = sFunctions.IsInTable
local ElevatorReplication = Overture:GetRemoteEvent("ElevatorReplication")
local floor0Position = 0
local floor1Position = 15
local floor2Position = 30
local floor3Position = 45
local floor4Position = 60
local floor5Position = 75
-- Main Code
for index, elevator in pairs(CollectionService:GetTagged("Elevator")) do
table.insert(Elevators, ElevatorClass:new(elevator))
end
-- CODE REMOVED FOR PRIVACY REASONS
for index, elevatorModel in pairs(CollectionService:GetTagged("Elevator")) do
ElevatorReplication.OnServerEvent:Connect(function(elevatorVar, floorVariable)
local Configuration = elevatorModel:WaitForChild("Configuration", 5)
-- repeat wait(1) until buttonVar:WaitForChild("FloorValue", 1) ~= nil
local retrieveFloorNumber = Retrieve("TempFloorValue", "NumberValue", Configuration)
local floorNumber = retrieveFloorNumber.Value
floorNumber = floorVariable
floorNumber = 4
local FloorNumber = Retrieve("FloorNumber", "NumberValue", Configuration)
local Moving = Retrieve("Moving", "BoolValue", Configuration)
if floorNumber ~= FloorNumber.Value then
local PrismaticConstraint = elevatorModel.Cabin.Mover.PrismaticConstraint
if floorNumber == 0 then
PrismaticConstraint.TargetPosition = floor0Position
elseif floorNumber == 1 then
PrismaticConstraint.TargetPosition = floor1Position
elseif floorNumber == 2 then
PrismaticConstraint.TargetPosition = floor2Position
elseif floorNumber == 3 then
PrismaticConstraint.TargetPosition = floor3Position
elseif floorNumber == 4 then
PrismaticConstraint.TargetPosition = floor4Position
elseif floorNumber == 5 then
PrismaticConstraint.TargetPosition = floor5Position
end
ElevatorClass:WaitForElevator(FloorNumber.Value, 4, elevatorModel, 4)
elseif floorNumber == FloorNumber.Value then
ElevatorClass:WaitForElevator(FloorNumber.Value, FloorNumber, elevatorModel, floorNumber)
end
end)
end
For some reason, code formatting wouldn't work, so I had to put it in a Pastebin. All help is greatly appreciated.
Thanks, Rook.

2 comments
Sorry too advanced 4 me. All i can say is check your spelling, indents, and capitals
Where are you print statements? Because "the proper value" is super vague and I have no idea what value you are talking about.