I'm pretty new to scripting, and currently, I'm working on making a simple "chat" function with NPCs for a game I'm creating. The concept is players would press F when in range with an NPC, and the chat begins. Now, I already have that all completed. The issue is how the script functions. You see, in ROBLOX Studio, everything works just fine. However, when I actually join the game and try it out there, it doesn't work whatsoever. Completely breaks. Here's each script and what happens with it in both Studio and ingame:
First, players enter a zone. When in the zone, an ImageLabel will show up that tells them to press the F key. Here's the code for that:
function Part(hit)
if script.Parent.Parent.Dummy.HumanoidRootPart.Key.Enabled == false then
script.Parent.Parent.Talk.Disabled = false
script.Parent.Parent.Dummy.HumanoidRootPart.Key.Enabled = true
script.Parent.Parent.Dummy.HumanoidRootPart.Key.ImageLabel:TweenSize(UDim2.new(0, 37, 0, 37), 'Out', 'Bounce', 0.5)
wait(0.5)
else
wait(0.5)
end
end
script.Parent.Touched:connect(Part)
That is the "toggle on" script, which I use to tell the game that the player is in range, and this activates a script that waits for the player to press the proper key. There's a toggle off, for when the player leaves the range, which basically just disables the script waiting for an F key and shrinks the image down to be invisible. The key script is here:
game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.F then
local player = game.Players.LocalPlayer
local Character = player.Character
Character.Humanoid.WalkSpeed = 0
Character.Humanoid.JumpPower = 0
wait(0.5)
script.Parent.Dummy.HumanoidRootPart.Key.ImageLabel:TweenSize(UDim2.new(0, 0, 0, 0), 'Out', 'Bounce', 0.5)
game.StarterGui.Speech.TalkScripts.test000.Disabled = false
game.StarterGui.Speech.BoxFrame.BackgroundTransparency = 1
print("check")
end
end)
All I currently put down was the game freezing the player, and then printing "check" in output, so I know everything works fine. In Studio, when I play test, everything works fine. The f key image shows up smoothly, and when I press F, it freezes me and prints in output. So, naturally, I assume it's all good. When I play ingame, however, there's a couple differences. For the script that enlarges the F key, it ends up working VERY slow, to a point where it just appears when the toggle on script activates, and then shrinks down to, like, 3x3 pixels, and then disappears on the toggle off script. Both of these scripts end up with a delay, way longer than the 0.5 seconds I put in the script. The script that activates upon pressing F doesn't even work anymore, and does absolutely nothing. No freeze, no print in output. I have absolutely NO idea why this is happening, but it's becoming a huge obstacle in finishing up just a simple NPC-chat feature. Sorry if I'm not supposed to put this here, but ROBLOX removed the forums, and this is the only site I could think of for help. Does anyone have any idea why this is happening?
EDIT: This game has Filtering Enabled. I toggled it off and on, and it had no affect on the key press script not working.
EDIT 2: The image label being slow on the tween command is fixed.
EDIT 3: The reason the key press script is not working has been narrowed down to be in the script itself. It's most likely within the function itself, as any print command placed after the function to figure out where it's breaking seems to not be printing at all, meaning the function itself is the issue.

2 comments
Is this game filtering enabled?
You need to multiply the values by 184923, its a bug that is being fixed