I’m making a turret and rn I’m trying to run a remote event that is a child of the turret but idk why its not working can someone help? The local script that is trying to find the remote event is inside a tool and the turret is inside a folder with the name of the player
inputService.InputBegan:Connect(function(input, gpe)
if gpe then return end
if equipp == true then
if input.KeyCode == Enum.KeyCode.R then
local mouse = player:GetMouse()
local turret = workspace.Sentinels:FindFirstChild(player.Name):FindFirstChild("Turret")
if turret then
local changeTarget = turret:FindFirstChild("ChangeTarget")
if mouse.Target then
local target = mouse.Target.Parent:FindFirstChild("HumanoidRootPart")
if target and changeTarget then
changeTarget:FireServer(target)
print(target)
else
print("missing something")
end
end
else
print(player.Name.." doesnt have a turret on")
end
end
end
end)
I did all and the local script is in fact finding the remote event, i printed the remote event name, class, parent, all, so it is finding, but not firing, the problem is not the function of the event since its just a print rn
okay thats quite weird, can you shwo me where the local script, and the server script are. show me the entire hierarchy. so show the whole thinglike this
i set remoteEvent to script.Parent on the server script that is a child of the remote event
im not having errors, the remote event just dont fire, all the print that should tell me that im having erros are not showing, just those who tell me that everything is fine
Had the same issue, and it’s really just Roblox Studio executing code in a weird order, basically local scripts load before server scripts or something like that, if you try it in-game it will work.
I am not sure if this is the case, but I suggest that you make sure
Guys, thank you to everyone who replied to this post; I’ve followed all of you. I managed to find the error in the script. I hadn’t mentioned it because I thought it was irrelevant, but now I see it was essential. Inside the remote event script, there was a while function checking for players near the part, and that was causing the problem. I thought the remote event would have priority over the while function, but apparently not. I placed the remote event above the while function, and then it worked. Thank you all, and sorry for the wasted time. @Bikereh@Sun_Battery23238@Bikereh
haha no worries. but while im here replying to you. instead of putting the remote event code above the loop, you can put the loop in a new thread. i would recommend you do it even if the loop is below the rest of you code. any code under the loop will stil run if its in a seperate thread. this is how you would do it:
task.spawn(function()
while true do
-- loop
end
end)
RemoteEvent.OnServerEvent:Connect(function(Player)
-- code
end)