Roblox Player server doesn't work but a Studio server does

This is obviously a very vague title, but I’ll try to give as much information as I can. It’ll get complicated I think, cuz I have a LOT of object classes imo.

Video Demonstrations of what is happening:
Studio Server:

Game Server:

Components (This’ll be long sorry):
TreeNode:
image

-CreateResourceGeneratorScript
local RunService = game:GetService("RunService");
local ResourceGenerator = require(script.ResourceGeneratorClass.Value);

local SendAttackEvent = script.SendAttackEvent.Value;

local rGenerator = ResourceGenerator.new(script.Parent, script.Parent.sPosPart.CFrame);
rGenerator:SetResource(game.ReplicatedStorage.Resources:FindFirstChild("2"));
rGenerator:GenerateResource();
script.Parent.Area:Destroy();
script.Parent.sPosPart.Transparency = 1;

SendAttackEvent.OnServerEvent:Connect(function( Player, plr, hitObject, damageValue )
	if ( rGenerator.resourceNode ~= nil ) then
		if ( rGenerator.resourceNode:CheckIfHit( hitObject ) == true ) then
			if ( rGenerator.resourceNode.Health > 0 ) then
				rGenerator.resourceNode:ApplyDamage( Player, damageValue );
			end
		end
	end
end)

Scripts & Models:
image
image

--ResourceNode Module
function ResourceNode:ApplyDamage(Player, damageValue)
	self:ApplyEffect(damageValue);
end

function ResourceNode:ApplyEffect(damageValue)
	if ( self.visualDebounce == false ) then
		self.visualDebounce = true;
		local newRandomVector = Vector3.new(math.rad(math.random(-10,10)), math.rad(math.random(-20,20)), math.rad(math.random(-10,10)))
		local RotateTween = TweenService:Create(self.PrimaryPart, self.PanelSwingInfo, {
			CFrame = self.PrimaryPart.CFrame * CFrame.Angles(newRandomVector.X, newRandomVector.Y, newRandomVector.Z)
			--CFrame = self.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(math.random(-20,20)), 0)
		});
		RotateTween:Play();
		self:SetState(damageValue);
	end

end
--ItemDrop Module
function ItemDrop.new(player, item, location, requestType)
	local self = setmetatable({}, ItemDrop);
	
	self.selectedPlayer = player;
	self.itemInfo = item;
	self.interactPing = InteractPingClass.new(self.selectedPlayer, self.itemInfo, "ItemDrop");
	
	return self;

end

function ItemDrop:OnUpdate(deltaTime) -- Check if player or players are close enough to pick up
	if (self.itemDropObject.Enabled.Value == true) then -- If drop is ready to be... dropped. Play item drop.
		local player = game.Players:FindFirstChild(self.selectedPlayer).Character
		local distanceBetween = math.abs((self.itemDropObject.Collider.Position - player.HumanoidRootPart.Position).Magnitude)
		
		if (distanceBetween < 10) then
			self.interactPing.frame.Properties.Distance.Value = distanceBetween;
			self.interactPing:Activate();
		else
			self.interactPing:Deactivate();
		end
	end
end

A quick little run down on how the events are supposed to work!
Player uses ToolController to attack a Resource Node generated by a ResourceGenerator via a client-to-server event. [When resource is hit it should run the “SetState” method to give it the visual effect]. When the resource is dead it spawns in a player specific itemgenerator into the server, and the itemdrops spawned by the generator pick the respective player to pick them up via a server-to-client event. To do this an InteractPing is created for each itemdrop and sent to the client of the player. When the player is in proximity the interactping will become visible in the player’s gui. When visible the player can press “e” and pick up the item. This is all the events taking place, but for some reason this only works in studio…

PLEASE let me know if more information is needed for certain parts. If I can think of any other factors that could cause this problem I’ll edit the post immediately!

Appreciate all the help I get!

1 Like

I fixed the problem! Had a heart attack from this…

It wasn’t included in ItemDrop.new but I had a:

RunService:BindToRenderStep()

which apparently doesn’t work in the Roblox Player.
Directly switching this to:

RunService.Heartbeat:Connect(function(deltaTime) self:OnUpdate(deltaTime) end)

fixed it.

I hope this helps anyone having issues with Modules/Classes working in the Roblox Player.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.