I was trying to make a function for the :Fire() on the remote event but it doesn’t run and when I copy and paste the code out from the function and paste it right in the RemoteEvent:Fire() it gives me the red squiggly line. I just want to know why its giving me an error line. Thanks in advance!
-- Code with the function
local RemoteEvent = Instance.new("RemoteEvent",ReplicatedStorage)
local function ServerFired()
local ActivatedButton = sf:FindFirstChild("TextButton"..cycle)
local TpPoints = workspace:FindFirstChild("TeleportPoints")
local character
local RequestedPoint
for point = 1, 15 do --Gets Requested points
if ActivatedButton.Name == ("TextButton"..point) then
RequestedPoint = TpPoints:FindFirstChild("Foundation"..point)
end
end
repeat
for cycle, object in ipairs(workspace:GetDescendants()) do
if object.Name == (player.Name) and obj:IsA("Model") then
character = object
end
end
for i = 5, 0, -1 do print(i) wait(1) end
until character print("Found character")
if RequestedPoint and character then
local pos = RequestedPoint.Position
--character:MoveTo(Vector3.new(pos.X, pos.Y + 5, pos.Z))
print("tped")
character:FindFirstChild(character.PrimaryPart.Name).Position = Vector3.new(pos.X, pos.Y + 5, pos.Z)
else print(" nil requested point")
end
end
RemoteEvent:FireServer(ServerFired)
-- Code that gives the squiggly red error line
RemoteEvent:FireServer(
local ActivatedButton = sf:FindFirstChild("TextButton"..cycle)
local TpPoints = workspace:FindFirstChild("TeleportPoints")
local character
local RequestedPoint
for point = 1, 15 do --Gets Requested points
if ActivatedButton.Name == ("TextButton"..point) then
RequestedPoint = TpPoints:FindFirstChild("Foundation"..point)
end
end
repeat
for cycle, object in ipairs(workspace:GetDescendants()) do
if object.Name == (player.Name) and obj:IsA("Model") then
character = object
end
end
for i = 5, 0, -1 do print(i) wait(1) end
until character print("Found character")
if RequestedPoint and character then
local pos = RequestedPoint.Position
--character:MoveTo(Vector3.new(pos.X, pos.Y + 5, pos.Z))
print("tped")
character:FindFirstChild(character.PrimaryPart.Name).Position = Vector3.new(pos.X, pos.Y + 5, pos.Z)
else print(" nil requested point")
end
)