I am using the FocusLost() function for a textbox, but theres a problem when firing a remoteevent, it simply does not fire. I checked on the server if the remote fires and prints something, but it doesnt.
local script:
local RemoteFolder = game.ReplicatedStorage:WaitForChild("ComputerEvents")
script.Parent.FocusLost:Connect(function(enterPressed)
if enterPressed then
if script.Parent.Text == "Island_Tower_Activate" then
game.ReplicatedStorage.ComputerEvents.UserActivateTower:FireServer()
end
end
end)
Add print statements in the event to see if they get through, before the enterpressed statement, after the enter pressed statement, and after the text checking
Both? I mentioned 3 prints to put, before the enterpressed statement, after the enterpressed statement, and after the statement when it checks the text. Are you sure you wrote Island_Tower_Activate correctly when testing?
Yes yes, i am very sure of that. the last print i put was right under the FireEvent() function, so not the local script is the problem
edit: i also checked what the server should do when it receives the event in the command bar, on run mode. the function works. so there may be a problem in getting the event…??
I do have, but it does not seem important. full code:
local value = workspace.Tower2.Activated
local value2 = workspace.Tower2.UserActivated
local interface = workspace.Interface.Interface
local randomval = math.random(60,240)
while true do
print(randomval)
wait(randomval)
if value.Value == true and value2.Value == true then
interface.ClickDetector.MaxActivationDistance = 32
value.Value = true
else
print("tower is deactivated")
end
wait(240)
if value.Value == false and value2.Value == false then
print("good job deactivating the tower")
else
interface.ClickDetector.MaxActivationDistance = 0
value.Value = false
print("xana won")
end
end
game.ReplicatedStorage.ComputerEvents.UserActivateTower.OnServerEvent:Connect(function()
game:GetService("Workspace").Tower2.UserActivated.Value = true
print("taken")
end)
Anytime! If you have anymore issues don’t be afraid to make another post! And yea, if you have code under an infinite loop that doesn’t break, it wont work because the script is stuck in the while loop, you either need to coroutine the loop or just put it as the last thing