Script works fine in studio but not game

Before we get started:
I think this is a roblox error, as nothing was changed and it randomly stopped working, no errors at all

Also don’t mind the trashy placement of it, i didnt put the text to scale

So my script used to work fine, nothing was changed at all, and has been used for a long while without problem, is also pretty compact.

please view these videos to get an understanding
STUDIO:

GAME:

1 Like

Have you published your game in Studio? Also, can you show the script?

Are you using Humanoid: LoadCharacterWithHumanoidDescription?
Any errors popping up in the console when you’re running it from the website?
If you put a print() on the clicking function does it print to console? If so how far down the chain will it print if you add more?

Yes
Localscript:


ReplicatedStorage = game:GetService("ReplicatedStorage")
MarketPlaceService = game:GetService("MarketplaceService")
GUI = script.Parent

Shop = GUI.Shop
TopBar = GUI.TopBar
Teams = GUI.Team
repeat
	wait()
until game:IsLoaded()

Modules = ReplicatedStorage.Modules
Gamepass = require(Modules.Gamepass)
Teamss = require(Modules.Teams)



-- Teams
for i,v in pairs(Gamepass) do
	local template = script.ShopTemplate:Clone()
	template.Parent = Shop
	template.Name = i
	template.TextLabel.Text = i
	if MarketPlaceService:UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId,v.id) then
		template.TextButton.Text = "Owned"
		template.TextButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
	else
		template.TextButton.MouseButton1Click:Connect(function(clikc)
			MarketPlaceService:PromptGamePassPurchase(game.Players.LocalPlayer,v.id)
		end)
	end
end

for _,v in pairs(Teams.Background:GetChildren()) do
	if Teamss[v.Name] then
		v.JoinTeamButton.MouseButton1Click:Connect(function(click)
			game.ReplicatedStorage.PlrTeamEvent:FireServer(v.Name)
		end)
	end
end


ShopOpen = false
TeamsOpen = false
TopBar.Gamepasses.MouseButton1Click:Connect(function(click)
	if ShopOpen then
		ShopOpen = not ShopOpen
		Shop:TweenPosition(UDim2.new(1,0,0.132,0),Enum.EasingDirection.In,Enum.EasingStyle.Linear,0.3)

	else
		ShopOpen = not ShopOpen
		Shop:TweenPosition(UDim2.new(0.267,0,0.132,0),Enum.EasingDirection.In,Enum.EasingStyle.Linear,0.3)

	end

end)

TopBar.Teams.MouseButton1Click:Connect(function(click)
	if TeamsOpen then
		TeamsOpen = not TeamsOpen
		Teams:TweenPosition(UDim2.new(1,0,0,0),Enum.EasingDirection.In,Enum.EasingStyle.Linear,0.3)

	else
		TeamsOpen = not TeamsOpen
		Teams:TweenPosition(UDim2.new(0,0,0,0),Enum.EasingDirection.In,Enum.EasingStyle.Linear,0.3)

	end

end)

Server

TeamEvent.OnServerEvent:Connect(function(plr,team)
	team = game.Teams:FindFirstChild(team)
	local t = Teams[team.Name]
	if Teams[team.Name] then
		if t[1] == "Free" then
			plr.TeamColor = team.TeamColor
			plr:LoadCharacter()
		else
			if plr:GetRankInGroup(t.id) >= t.minrank then
				plr.TeamColor = team.TeamColor
				plr:LoadCharacter()
			end
		end
	end
end)

Nothing it just running at all in-game, its worked fine in studio and game, it worked yesterday and no other dev has published in-between

FIX: Apparently one of my modules had a error that was not showing in studio for some reason, this was preventing the team module from hooking

1 Like

Also I know this isn’t the question and you already solved it, but I think you should add a teleport screen to let everything load in because when I watched the studio video some stuff weren’t loaded in and I think it would be an easy fix.

Thats actually a good idea, ill have to look into it