Interaction script wont work

I have no idea why my script isn’t working, Ive tried everything. Cant seem to get it to work.

local inputservice = game:GetService("UserInputService")
inputservice.InputBegan:connect(function(i,g)
	local Player = game.Players.LocalPlayer;
	if i.UserInputType == Enum.UserInputType.Keyboard then
		for _,Part in pairs(workspace.Interactions:GetChildren()) do
			local Mag = (script.Parent.Center.Position-Player.Character.HumanoidRootPart.Position).magnitude
			if Mag <= Part.Range.Value then
				local namef = Part.Event:FireServer("name")
				script.Parent.Frame.TextLabel.Text = tostring(namef)
				if i.KeyCode == Enum.KeyCode.F then
					script.Parent.Frame.Frame.Rotation = tonumber(20)
					wait(1.5)
					script.Parent.Frame.Frame.Rotation = tonumber(0)
					wait(0.5)
					Part.Event:FireServer("run")
				end
			end
		end
	end
end)

while wait() do
	script.Parent.Frame.Visible = false 
	for i,v in pairs(game.Workspace.Interactions:GetChildren()) do 
		local mag = (v.Center.Position-game.Players.LocalPlayer.Character.HumanoidRootPart.Position).magnitude 
		if mag <= 10 then 
			local WSP = game.Workspace.CurrentCamera:WorldToScreenPoint(v.Center.Position) 
			script.Parent.Frame.Visible = true
			script.Parent.Frame.Position = UDim2.new(0,WSP.X,0,WSP.Y)
		end
	end
end
script.Parent.Event.OnServerEvent:Connect(function(Player, c)
	local Mag = (script.Parent.Center.Position-Player.Character.HumanoidRootPart.Position).magnitude
	if Mag <= script.Parent.Range.Value then
		if c == "run" then
			Player.Character:MoveTo(game.Workspace.MenuSpawn.Position);
			Player.Character.Humanoid.WalkSpeed = 0
		elseif c == "name" then
			return "Enter Blackhawk"
		end
	end
end)

What exactly is it supposed to do? Additionally have your tried printing after some conditional statements?

3 Likes

I have fixed the issue, no help is needed.

1 Like