So I've been working on an Interaction system. It works perfectly in Studio but not in the Game. I've checked the script multiple times and I'm not seeing any errors, plus nothing comes up on the output after the print
lines. Here's my script:
--Vars local player = game.Players.LocalPlayer --Local Player local UIS = game:GetService("UserInputService") --UserInputService local val = player.InterObject --ObjectValue to determine what we're interacting with local SEvent = workspace.ScriptEventService.ChangeServerSide --A RemoteEvent used by Client to change something on the Server local InterGui = script.Parent.Parent.InteractGui --The InteractGui local F = Enum.KeyCode.F --F Keybind local G = Enum.KeyCode.G --G Keybind local E = Enum.KeyCode.E --E Keybind local InterKey = nil --Current key being held local Scoped = false --Determines whether player is in ADS with gun local KnockingOut = false --Determines if a player is knocking out NPC local holdingWeapon = false --Checks if Player is holding weapon local currentWeaponType = nil --Primary/Secondary weapon --Interaction Main UIS.InputBegan:Connect(function(input) --Begin Input if player.Interacting.Value == false then --Makes sure player is not interacting with anything else if val.Value ~= nil then --Makes sure the val is not empty if val.Value.Parent.Name == "OutterCamera" then --Makes sure we're interacting with the right object if val.Value.Parent.Broken.Value == false then --Makes sure this cam isn't already broken if input.KeyCode == F then --Checks Client is holding F SEvent:FireServer(player.Interacting, "Value", true) --Set Interacting.Value to true wait(0.1) --Delay InterKey = F --Set InterKey --Status SEvent:FireServer(player.PlayerGui.MainStats.Status, "Text", "Suspicious") SEvent:FireServer(player.PlayerGui.MainStats.Status, "TextColor3", Color3.fromRGB(170, 0, 0)) local num = 0 repeat num = num +1 --Add a num InterGui.F["Block"..num].Visible = true --Make Progress Bar fill wait(0.05) --Delay until num >= 100 or player.Interacting.Value == false or (player.InterObject.Value.Position - player.Character.Head.Position).Magnitude >= 5 --Finish conditions if num >= 100 then print("Interaction Complete") script.Parent.InteractItems.Camera:FireServer() elseif player.Interacting.Value == false then print("Stopped Interaction") elseif (player.InterObject.Value.Position - player.Character.Head.Position).Magnitude >= 7.75 then print("Too far away") --I got more of the important stuff around here, don't worry about them. I just need help with these lines
Does anybody have any idea what's wrong with it? Help would be greatly appreciated