Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Works in studio but not in game?

I've been animating enemies for my game recently and I've had a good base with a model I've been using, but there are some serious problems. The enemy works almost perfectly in studio (however if I put two or more, they attack each other which needs to be fixed) but is completely broken in-game. It will still chase players and attack them, but the animations don't work and some actions cause it to break.

The model itself has too many scripts for me to post here. However, the link leads to the model and can be opened up in studio to be dug into. Any suggestions?

http://www.roblox.com/Drooling-Zombie-item?id=187789986

Basic Script~

local zombie = script.Parent

for _, script in pairs(zombie.ModuleScripts:GetChildren()) do
	if not game.ServerStorage:FindFirstChild(script.Name) then
		script:Clone().Parent = game.ServerStorage
	end
end

local AI = require(game.ServerStorage.ROBLOX_ZombieAI).new(zombie)
local DestroyService = require(game.ServerStorage.ROBLOX_DestroyService)


local function clearParts(parent)
	for _, part in pairs(parent:GetChildren()) do
		clearParts(part)
	end
	local delay
	if parent:IsA("Part") then
		delay = math.random(5,10)
	else
		delay = 11
	end
	DestroyService:AddItem(parent, delay)
end

zombie.Humanoid.Died:connect(function()
	AI.Stop()
	math.randomseed(tick())
	clearParts(zombie)
	script.Disabled = true
end)

local lastMoan = os.time()
math.randomseed(os.time())
while true do
	local animationTrack = zombie.Humanoid:LoadAnimation(zombie.Animations.Arms)
	animationTrack:Play()
--	local now = os.time()
--	if now - lastMoan > 5 then	
--		if math.random() > .3 then
--			zombie.Moan:Play()
----			print("playing moan")
--			lastMoan = now
--		end
--	end
	wait(2)
end

5 comments

0

Post the script please, I believe I know what the problem is.

0

Whatever it is shouldn't have a bunch of scripts. Realistically, every instance of it should be controlled entirely by one script.

0

I hope this is what you wanted to see.

0

Is it in a local script? If not put it in it or vice versa.

0

I tried local, now they won't even move. So i didn't go through with that.

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.