Game not fully publishing solely scripts from Studio to Roblox

Hi DevForum,

I don’t necessarily think this is the wrong category to post this, but I’ve been having an issue with my game “Publishing to Roblox”.

What I mean by this is pretty much I’ve been saving and publishing my game from Studio to Roblox, and keep in mind everything works fine in studio, yet when I join the actual game on Roblox, no scripts work. If anything, the models are updated, such as if I add a dummy to workspace, it will update to roblox, yet my scripts do not work. Any fixes? Thanks a bunch!

Hi! Have you tried looking at the dev console (server) in game? Perhaps you can make a script with a print statement saying “script running” or something along the lines to check if it is an internal issue or not. The reason I suggest this is I just tested my experiences and they seem to work as intended. Hope this helps!

Hello!

Yes, I have tested, and for some reason, it still won’t work. If you need more details, it’s a script in StarterPlayer that involves UserInputService, yet it still won’t receive any print statements, although in Studio it does.

Oh I see! Ok in that case, can you send me your script? I have a similar system, so I use a local script and structure it as follows:

local UserInputService = game:GetService("UserInputService")
local Player = game:GetService("Players").LocalPlayer

local frame = Player.PlayerGui.ScreenGui:WaitForChild("Frame")

local function OnInputBegan(input) 
if input.KeyCode == Enum.KeyCode.M then
		frame.Visible = true
		print("The M key was pressed.")
	end
end

UserInputService.InputBegan:Connect(onInputBegan)

I wouldn’t recommend putting a regular script instead of a Local Script since that did not work for me, but Local Script is definitely the method I would use!

Sure thing!

local UIS = game:GetService("UserInputService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")

local Events = ReplicatedStorage:WaitForChild("Events")
local RemoteEvent = Events.RemoteEvent

local player = Players.LocalPlayer
local character = player.CharacterAdded:Wait()
local hrp = character.HumanoidRootPart
local rightHand = character.RightHand

local cooldown = false
local cdTime = 2.5

print("Running")

UIS.InputBegan:Connect(function(input, isTyping)
	if isTyping then return end

	print("Passed GPE")

	if input.KeyCode == Enum.KeyCode.R then
		print("R pressed, not passed yet.")
		if not cooldown then
			print("R Pressed!")

			cooldown = true

			RemoteEvent:FireServer()

			print("Fired!")
			wait(cdTime)
			cooldown = false
		end
	end
end)

Ignore all of the print statements, that was me trying to test them, and they only work in studio.

1 Like

I have found your issue! It seems that there is something wrong with the following lines:

local character = player.CharacterAdded:Wait()
local hrp = character.HumanoidRootPart
local rightHand = character.RightHand

My guess is that it is indefinitely waiting for character, which probably exists but is not returning any error (such infinite yield, etc), not sure why is that the particular issue, but upon further inspection by removing those statements, it is printing the inputs. Here is the script I was using:

local UIS = game:GetService("UserInputService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")

local Events = ReplicatedStorage["Events"]
local RemoteEvent = Events:WaitForChild("RemoteEvent")

local player = Players.LocalPlayer

local cooldown = false
local cdTime = 2.5

print("Running")

UIS.InputBegan:Connect(function(input, isTyping)
	if isTyping then return end

	print("Passed GPE")

	if input.KeyCode == Enum.KeyCode.R then
		print("R pressed, not passed yet.")
		if not cooldown then
			print("R Pressed!")

			cooldown = true

			RemoteEvent:FireServer()

			print("Fired!")
			wait(cdTime)
			cooldown = false
		end
	end
end)

1 Like

Thanks so much, I had to remove that from two separate scripts to get them working.

1 Like

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