Script not working in game

I am trying to get this script that I made to work in the game, however for some odd reason the script only functions correctly in the studio version.

this issue is that it wont work when playing a regular Roblox game.

I have already tried moving the script around, spamming publish to make sure it applies, and debugging and the prints and everything work.

the scripts location is:
game>StarterPlayer>StarterPlayerScripts>CombatScript.

You’ll need to share what the script does or the code in the script so we can get a understanding of what’s going on.

1 Like

Alright here it is.

Please note that I’ve just started working on it like a day ago so still working a few things out, therefor apologies for any undefined variables, or bad code etiquette.

local BREAK_COMBAT = false

local players = game:GetService("Players")

local player = game.Players.LocalPlayer

workspace:WaitForChild("FightSys")

local char = player.Character

if not char or not char.Parent then
	
	char = player.CharacterAdded:Wait()
	
end

local TS = game:GetService("TweenService")

local humanoid = char:WaitForChild("Humanoid")

local animator = humanoid:WaitForChild("Animator")

local UIS = game:GetService("UserInputService")


--//Creating Hitbox


---

local AT = {
	
	["Fighting"] = false,
	
	["Blocking"] = false,
	
	["FightingStance"] = "rbxassetid://7423112210",

["BlockStance"] = "rbxassetid://7423840292",
	
	["Animations"] = {
		
	--
	["Ljab"] = {
		
		["ID"] = "rbxassetid://7423204629",
		
		["Damage"] = 2,
		
		["C"] = false,
		
		["N"] = "Ljab",
		
		["CT"] = 1,
		
		["Type"] = "Punch_Fist",
		
		
		["AOE"] = {
			
			
			["LeftHand"] = true,
			
		},
		
		},
	["Rjab"] = {

		["ID"] = "rbxassetid://7423405060",
		
		["C"] = false,
		
		["CT"] = 1,
		
		["Damage2"] = 1,

		["Type"] = "Punch_Fist",

		["AOE"] = {	

			["RightHand"] = true,

		}

	}

},
	
}


--//Instancing Animations
local FightingStance = Instance.new("Animation")

local BlockStance = Instance.new("Animation")

-----------------------------------------------
--Setting Animations

FightingStance.AnimationId = AT["FightingStance"]

BlockStance.AnimationId = AT["BlockStance"]

--Loading Animations
local fightstanceload = humanoid:LoadAnimation(FightingStance)

local blockstanceload = humanoid:LoadAnimation(BlockStance) --[[Setting]] 



----------------------------------------------------------------



UIS.InputEnded:Connect(function(k, p)
	
	if p then return end
	
	if k.KeyCode == Enum.KeyCode.F then
		
		print("Run")
		
		AT["Blocking"] = false
		blockstanceload:Stop()
		
		workspace.FightSys["</>"].Script.RemoteEvent:FireServer("InsertBlockvalue", AT["Blocking"])
		
		if AT["Fighting"] == true then
			
			blockstanceload:Stop()
			
			fightstanceload:Play()
			
		end
		
	end
	
end)




UIS.InputBegan:Connect(function(k, p)

	if p then return end

	if k.KeyCode == Enum.KeyCode.F then
		
		--block
		
		AT["Blocking"] = true
		
		workspace.FightSys["</>"].Script.RemoteEvent:FireServer("InsertBlockvalue", AT["Blocking"])
		fightstanceload:Stop()
		
		blockstanceload:Play()
		
		
		
	end



if k.KeyCode == Enum.KeyCode.B then

		--Fight Stance Toggle
		
		if AT["Fighting"] == false then
		
		fightstanceload:Play()
		
		blockstanceload:Stop()
		
		AT["Blocking"] = false
		
		AT["Fighting"] = true
		print("Ran")
		
		elseif AT["Fighting"] == true then
			
			AT["Blocking"] = false
			
			blockstanceload:Stop()
			
			fightstanceload:Stop()
			
			AT["Fighting"] = false
		
		end

	end
end)

--fight portion

local fs = workspace.FightSys

local mouse = game.Players.LocalPlayer:GetMouse()

local function CoolDownHandler(v1,v2,v3)
	
	wait(v1["CT"])
	
	v1["C"] = false
	
	print("Clear Cooldown")
	
end


mouse.Button1Down:Connect(function()
	
	if AT["Blocking"] == true then return end
	
	if AT["Fighting"] == true then
		

	local anim = Instance.new("Animation")
	
	anim.AnimationId = AT["Animations"]["Ljab"]["ID"]

	local loadanim = humanoid:LoadAnimation(anim)
	
	loadanim:Play()
	
	for i, v in pairs(AT["Animations"]["Ljab"]["AOE"]) do
		
		local ee
		
		ee=	game.Players.LocalPlayer.Character[i].Touched:Connect(function(t)
			
			spawn(function(FixDisconnect)

				wait(.45)
				ee:Disconnect()


			end)

			if t.Parent:FindFirstChild("Humanoid") then
				
				if ee then
					
				ee:Disconnect()
				
				end
				
				workspace.FightSys["</>"].Script.RemoteEvent:FireServer(AT["Animations"]["Ljab"]["Damage"], t.Parent.Name, t.Name)

			end


		end)

	end	
	
	local window = true
	
	local catch = false


	local e 
	
	spawn(function()

		--Close window

		for i = 1,2 do
			wait(.25)

			if i == 2 then

				window = false

				if e then

					e:Disconnect()

				end
			end

		end

	end)
	
	e = UIS.InputBegan:Connect(function(k, p)
		

		if p then 
		
		else
			
			if k.KeyCode == Enum.KeyCode.R then
			
			if window then
				
				e:Disconnect()

				catch = true
				
			else
				
				e:Disconnect()
				
			end
			
			end
		end
		
	end)


	loadanim.Stopped:Connect(function()
					
					if catch then
						
						e:Disconnect()

						local anim2 = Instance.new("Animation")

						anim2.AnimationId = AT["Animations"]["Rjab"]["ID"] 

						local load2 = humanoid:LoadAnimation(anim2)
					
						loadanim:Stop()
						
						load2:Play()
						
					for i, v in pairs(AT["Animations"]["Rjab"]["AOE"]) do
						local ee
					ee=	game.Players.LocalPlayer.Character[i].Touched:Connect(function(t)
							
							spawn(function(FixDisconnect)
								
								wait(.45)
								ee:Disconnect()
								
								
							end)
							
							if t.Parent:FindFirstChild("Humanoid") then
								if ee then
								ee:Disconnect()
								end
								workspace.FightSys["</>"].Script.RemoteEvent:FireServer(AT["Animations"]["Rjab"]["Damage"], t.Parent.Name, t.Name)
								
							end
							
							
						end)
						
					end		
		
			end
	
		end)
	
	end

	
end)

could FightSys not be available? Put a ,20 next to the string so it has a timeout of 20 and see what happens

I thought i uploaded a video but here that is

Just to get this out of the way. Whenever something works in Studio but not in-game for me, I make sure I have API Services turn on.

Oh yeahh that might be the problem, lemme try turning it on. I always turn all of them on too guess I spaced.

1 Like

unfortunately turning this on didnt fix it.

Oof and you aren’t getting any errors?

No, there is no errors. I sent the script if you wanna read through it but if its working in studio i cant think of any reason for this to not be working…

1 Like

I can’t really think of anything else either. Sorry but I’ll let you know if I think of anything.

thank you for trying. I’ll be on the lookout,

1 Like

Where, and I would assume this would raise an error? Why would it only not be available in the game. I will try it but I wanna know the reasoning behind this explanation.

regardless @lanjtlike, I doubt this is a problem because 1. The script would not execute further if that were the case, and in the game the script is executing its just not working for half of it it only runs one part and half the stuff isn’t loading. however it works in studios. there’s no “infinite yield possible” errors in console.

The problem is probably in this remote event. If there is any code that needs to be on the client in there, it would work in studio because the server is also the client but might not work in game.

From the looks of this, it seems to me that one possible reason is that those animations were made and exported on someone’s else’s account. For some reason, animations owned by someone else will play in studio but they won’t play in the actual game.

Were you the creator of those animations or did a friend animate those for you?

the animation is owned by the studio which we are all a part of.

the event is firing and receiving though.

I think that might be the problem.

I was able to find some of the animations using the animation IDs found in the script that you sent (above). Only one animation (Imported Animation Clip - Roblox) is owned by the group (FallFusion Studios).
The other ones (Imported Animation Clip - Roblox, Imported Animation Clip - Roblox, Imported Animation Clip - Roblox) are owned by you and are not part of the group.

If you export those animations into the group’s inventory and replace the old IDs with the new ones, those animations should work in the game.