Hey Developers,
I have some issue with input service .It didn’t detect when player pressing E. No error was found and I tried do debugging and found that the script at line 17 didn’t print at all. I cant find any solution for my problem .This is my script:
local player = game.Players.LocalPlayer
local bill = script.Parent.BillboardGui
local but = bill.TextButton
local doorparent = game.Workspace.Door
local UseInputService = game:GetService("UserInputService")
UseInputService.InputBegan:Connect(function(input, gameproces)
if not gameproces then
for i , v in pairs(doorparent:GetChildren())do
if (player.Character.HumanoidRootPart.Position - v.Door.Position).Magnitude < 15 then
print("nearby passenger")
if bill.Adornee ~= v then
print("xeneser")
print("ok")
bill.Adornee = v
print("k")
if input.KeyCode == Enum.KeyCode.E and bill.Adornee == v then
print("buur")
game.ReplicatedStorage.RemoteEvent.OpenDoorEvent.OpenDoorBar:FireServer(v.Hinge)
print(bill.Adornee)
end
end
end
end
end
end)
local player = game.Players.LocalPlayer
local bill = script.Parent.BillboardGui
local but = bill.TextButton
local doorparent = game.Workspace.Door
local UseInputService = game:GetService("UserInputService")
UseInputService.InputBegan:Connect(function(input, gameproces)
for i , v in pairs(doorparent:GetChildren())do
if (player.Character.HumanoidRootPart.Position - v.Door.Position).Magnitude < 15 then
bill.Adornee = v
print("nearby passenger")
if not gameproces then
if input.KeyCode == Enum.KeyCode.E then
if bill.Adornee == v then
print(v)
wait(.5)
print("xeneser")
print("buur")
game.ReplicatedStorage.RemoteEvent.OpenDoorEvent.OpenDoorBar:FireServer(v.Hinge)
print(bill.Adornee)
end
end
end
end
end
end)
When I’m firing remote event it didnt fired but it only print instead
Which prints aren’t occurring, if they all are occurring, then the remote event is firing and there’s something wrong with the receiving of your remote event.
local tweenService = game:GetService("TweenService")
local ti = TweenInfo.new(1)
local function StartTween(part)
local hinge = part
local goal = {}
goal.CFrame = hinge.CFrame * CFrame.Angles(0,math.rad(-90),0)
local ended = {}
ended.CFrame = hinge.CFrame * CFrame.Angles(0,0,0)
local startingtween = tweenService:Create(hinge,ti,goal)
local edningtween = tweenService:Create(hinge,ti,ended)
end
game.ReplicatedStorage.RemoteEvent.OpenDoorEvent.OpenDoorBar.OnServerEvent:Connect(function(StartTween)
print("bruh im not running")
end)
Your code needs a lot of refactoring! It is hard to read and that’s why it comes hard to find a solution to your problem, one thing is that you should use guard clauses within this portion. Example:
UserInputService.InputBegan:Connect(function(input, gameProcessEvent)
if gameProcessEvent then return end
end)
This avoids nested if logic and it is better to our eyes, to be honest. Is basically checking if gameProcessEvent it is true and ending the function if that’s the case!
Ah I see the issue, your first parameter needs to be the player, secondly you’re sending the hinge of the door so it can’t be the start tween as the parameter. Inside the remote event function, then you can call the StartTween function
Yes no problem! Basically the parameter gameProcessEvent refers to the game engine that got this input and acted on it. Lets have an example, if a button was pressed within this input, gameProcessEvent will be true, also this is when we’re chatting. When we are using the chat to communicate with other players and you put some input (like if our input detection was the E) and we pressed the E while doing so, the parameter gameProcessEvent will be true.
The InputBegan it is fired everytime there’s any input registration by the engine it-self.
Agreed with him, you can’t put the function keyword and then put the name of the function where the parameters should go. The OnServerEvent always takes in a player as the first parameter as well. So you would send StartTween(player, args).